Skip to content

Commit 755ed28

Browse files
committed
Update to latest jsonld.js.
1 parent 0518632 commit 755ed28

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

playground/jsonld.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4486,7 +4486,7 @@ function _prependBase(base, iri) {
44864486
// append relative path to the end of the last directory from base
44874487
if(rel.pathname !== '') {
44884488
path = path.substr(0, path.lastIndexOf('/') + 1);
4489-
if(path.length > 0 && path.lastIndexOf('/') !== path.length - 1) {
4489+
if(path.length > 0 && path.substr(-1) !== '/') {
44904490
path += '/';
44914491
}
44924492
path += rel.pathname;
@@ -4531,7 +4531,7 @@ function _removeBase(base, iri) {
45314531
if(base.href !== '') {
45324532
root += (base.protocol || '') + '//' + base.authority;
45334533
}
4534-
// scheme-relative root with empty base
4534+
// support network-path reference with empty base
45354535
else if(iri.indexOf('//')) {
45364536
root += '//';
45374537
}
@@ -4560,8 +4560,7 @@ function _removeBase(base, iri) {
45604560
var rval = '';
45614561
if(baseSegments.length > 0) {
45624562
// do not count the last segment if it isn't a path (doesn't end in '/')
4563-
if(base.normalizedPath.indexOf(
4564-
'/', base.normalizedPath.length - 1) === -1) {
4563+
if(base.normalizedPath.substr(-1) !== '/') {
45654564
baseSegments.pop();
45664565
}
45674566
for(var i = 0; i < baseSegments.length; ++i) {
@@ -6189,36 +6188,27 @@ else {
61896188
* @param parsed the pre-parsed URL.
61906189
*/
61916190
function _parseAuthority(parsed) {
6192-
// parse authority for relative network-path reference
6193-
if(parsed.href.indexOf(':') === -1 && parsed.href.indexOf('//') === 0) {
6194-
// authority already parsed, pathname should also be correct
6195-
if(parsed.host) {
6196-
parsed.authority = parsed.host;
6197-
if(parsed.auth) {
6198-
parsed.authority = parsed.auth + '@' + parsed.authority;
6199-
}
6200-
}
6191+
// parse authority for unparsed relative network-path reference
6192+
if(parsed.href.indexOf(':') === -1 && parsed.href.indexOf('//') === 0 &&
6193+
!parsed.host) {
62016194
// must parse authority from pathname
6195+
parsed.pathname = parsed.pathname.substr(2);
6196+
var idx = parsed.pathname.indexOf('/');
6197+
if(idx === -1) {
6198+
parsed.authority = parsed.pathname;
6199+
parsed.pathname = '';
6200+
}
62026201
else {
6203-
parsed.pathname = parsed.pathname.substr(2);
6204-
var idx = parsed.pathname.indexOf('/');
6205-
if(idx === -1) {
6206-
parsed.authority = parsed.pathname;
6207-
parsed.pathname = '';
6208-
}
6209-
else {
6210-
parsed.authority = parsed.pathname.substr(0, idx);
6211-
parsed.pathname = parsed.pathname.substr(idx);
6212-
}
6202+
parsed.authority = parsed.pathname.substr(0, idx);
6203+
parsed.pathname = parsed.pathname.substr(idx);
62136204
}
62146205
}
62156206
else {
62166207
// construct authority
6217-
parsed.authority = '';
6208+
parsed.authority = parsed.host || '';
62186209
if(parsed.auth) {
6219-
parsed.authority += parsed.auth + '@';
6210+
parsed.authority = parsed.auth + '@' + parsed.authority;
62206211
}
6221-
parsed.authority += (parsed.host || '');
62226212
}
62236213
}
62246214

0 commit comments

Comments
 (0)