| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ee02739 commit 9aeda47
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -294,22 +294,29 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { | |||
| 294 | 294 | rest = rest.slice(proto.length); | |
| 295 | 295 | } | |
| 296 | 296 | ||
| 297 | - // Figure out if it's got a host | ||
| 298 | - // user@server is *always* interpreted as a hostname, and url | ||
| 297 | + // Figure out if it's got a host. | ||
| 298 | + // user@server is *always* interpreted as a hostname, and URL | ||
| 299 | 299 | // resolution will treat //foo/bar as host=foo,path=bar because that's | |
| 300 | - // how the browser resolves relative URLs. | ||
| 300 | + // how the browser resolves relative URLs. http:@example.com is treated | ||
| 301 | + // the same as http://example.com. | ||
| 301 | 302 | let slashes; | |
| 303 | + let at; | ||
| 302 | 304 | if (slashesDenoteHost || proto || hostPattern.test(rest)) { | |
| 303 | 305 | slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH && | |
| 304 | - rest.charCodeAt(1) === CHAR_FORWARD_SLASH; | ||
| 305 | - if (slashes && !(proto && hostlessProtocol.has(lowerProto))) { | ||
| 306 | - rest = rest.slice(2); | ||
| 307 | - this.slashes = true; | ||
| 306 | + rest.charCodeAt(1) === CHAR_FORWARD_SLASH; | ||
| 307 | + at = rest.charCodeAt(0) === CHAR_AT; | ||
| 308 | + if (!(proto && hostlessProtocol.has(lowerProto))) { | ||
| 309 | + if (slashes) { | ||
| 310 | + rest = rest.slice(2); | ||
| 311 | + this.slashes = true; | ||
| 312 | + } else if (at) { | ||
| 313 | + rest = rest.slice(1); | ||
| 314 | + } | ||
| 308 | 315 | } | |
| 309 | 316 | } | |
| 310 | 317 | ||
| 311 | 318 | if (!hostlessProtocol.has(lowerProto) && | |
| 312 | - (slashes || (proto && !slashedProtocol.has(proto)))) { | ||
| 319 | + (slashes || at || (proto && !slashedProtocol.has(proto)))) { | ||
| 313 | 320 | ||
| 314 | 321 | // there's a hostname. | |
| 315 | 322 | // the first instance of /, ?, ;, or # ends the host. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -975,7 +975,22 @@ const parseTests = { | |||
| 975 | 975 | query: null, | |
| 976 | 976 | pathname: '/everybody', | |
| 977 | 977 | path: '/everybody', | |
| 978 | - href: '//fhqwhgads@example.com/everybody#to-the-limit' | ||
| 978 | + href: '//fhqwhgads@example.com/everybody#to-the-limit', | ||
| 979 | + }, | ||
| 980 | + | ||
| 981 | + 'http:@localhost': { | ||
| 982 | + protocol: 'http:', | ||
| 983 | + slashes: null, | ||
| 984 | + auth: null, | ||
| 985 | + host: 'localhost', | ||
| 986 | + port: null, | ||
| 987 | + hostname: 'localhost', | ||
| 988 | + hash: null, | ||
| 989 | + search: null, | ||
| 990 | + query: null, | ||
| 991 | + pathname: '/', | ||
| 992 | + path: '/', | ||
| 993 | + href: 'http://localhost/', | ||
| 979 | 994 | }, | |
| 980 | 995 | }; | |
| 981 | 996 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments