Skip to content

Commit 71a41f4

Browse files
committed
Update to latest jsonld.js.
1 parent 6844212 commit 71a41f4

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

playground/jsonld.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6152,7 +6152,7 @@ else {
61526152
// MIT License
61536153
var parseUri = {};
61546154
parseUri.options = {
6155-
key: ['href','protocol','host','userInfo','user','password','hostname','port','relative','path','directory','file','query','hash'],
6155+
key: ['href','protocol','host','auth','user','password','hostname','port','relative','path','directory','file','query','hash'],
61566156
parser: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/
61576157
};
61586158
jsonld.url.parse = function(str) {
@@ -6173,7 +6173,9 @@ else {
61736173
if(uri.query) {
61746174
uri.path = uri.path + '?' + uri.query;
61756175
}
6176-
uri.protocol += ':';
6176+
if(uri.protocol) {
6177+
uri.protocol += ':';
6178+
}
61776179
if(uri.hash) {
61786180
uri.hash = '#' + uri.hash;
61796181
}
@@ -6187,17 +6189,27 @@ else {
61876189
* @param parsed the pre-parsed URL.
61886190
*/
61896191
function _parseAuthority(parsed) {
6190-
// parse authority for network-path reference
6191-
if(parsed.href.indexOf('//') === 0) {
6192-
parsed.pathname = parsed.pathname.substr(2);
6193-
var idx = parsed.pathname.indexOf('/');
6194-
if(idx === -1) {
6195-
parsed.authority = parsed.pathname;
6196-
parsed.pathname = '';
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+
}
61976200
}
6201+
// must parse authority from pathname
61986202
else {
6199-
parsed.authority = parsed.pathname.substr(0, idx);
6200-
parsed.pathname = parsed.pathname.substr(idx);
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+
}
62016213
}
62026214
}
62036215
else {

0 commit comments

Comments
 (0)