@@ -6152,7 +6152,7 @@ else {
6152
6152
// MIT License
6153
6153
var parseUri = { } ;
6154
6154
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' ] ,
6156
6156
parser : / ^ (?: ( [ ^ : \/ ? # ] + ) : ) ? (?: \/ \/ ( (?: ( ( [ ^ : @ ] * ) (?: : ( [ ^ : @ ] * ) ) ? ) ? @ ) ? ( [ ^ : \/ ? # ] * ) (?: : ( \d * ) ) ? ) ) ? ( ( ( (?: [ ^ ? # \/ ] * \/ ) * ) ( [ ^ ? # ] * ) ) (?: \? ( [ ^ # ] * ) ) ? (?: # ( .* ) ) ? ) /
6157
6157
} ;
6158
6158
jsonld . url . parse = function ( str ) {
@@ -6173,7 +6173,9 @@ else {
6173
6173
if ( uri . query ) {
6174
6174
uri . path = uri . path + '?' + uri . query ;
6175
6175
}
6176
- uri . protocol += ':' ;
6176
+ if ( uri . protocol ) {
6177
+ uri . protocol += ':' ;
6178
+ }
6177
6179
if ( uri . hash ) {
6178
6180
uri . hash = '#' + uri . hash ;
6179
6181
}
@@ -6187,17 +6189,27 @@ else {
6187
6189
* @param parsed the pre-parsed URL.
6188
6190
*/
6189
6191
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
+ }
6197
6200
}
6201
+ // must parse authority from pathname
6198
6202
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
+ }
6201
6213
}
6202
6214
}
6203
6215
else {
0 commit comments