Skip to content

Commit 96a9e00

Browse files
aduh95sxa
authored andcommitted
url: revert fix url.parse() for @hostname
This reverts commit 010cb71. Refs: #42279 PR-URL: #42280 Fixes: #42279 Reviewed-By: Stewart X Addison <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent ea81c5e commit 96a9e00

File tree

2 files changed

+9
-31
lines changed

2 files changed

+9
-31
lines changed

lib/url.js

+8-15
Original file line numberDiff line numberDiff line change
@@ -294,29 +294,22 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
294294
rest = rest.slice(proto.length);
295295
}
296296

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
299299
// resolution will treat //foo/bar as host=foo,path=bar because that's
300-
// how the browser resolves relative URLs. http:@example.com is treated
301-
// the same as http://example.com.
300+
// how the browser resolves relative URLs.
302301
let slashes;
303-
let at;
304302
if (slashesDenoteHost || proto || hostPattern.test(rest)) {
305303
slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH &&
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-
}
304+
rest.charCodeAt(1) === CHAR_FORWARD_SLASH;
305+
if (slashes && !(proto && hostlessProtocol.has(lowerProto))) {
306+
rest = rest.slice(2);
307+
this.slashes = true;
315308
}
316309
}
317310

318311
if (!hostlessProtocol.has(lowerProto) &&
319-
(slashes || at || (proto && !slashedProtocol.has(proto)))) {
312+
(slashes || (proto && !slashedProtocol.has(proto)))) {
320313

321314
// there's a hostname.
322315
// the first instance of /, ?, ;, or # ends the host.

test/parallel/test-url-parse-format.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -975,22 +975,7 @@ const parseTests = {
975975
query: null,
976976
pathname: '/everybody',
977977
path: '/everybody',
978-
href: '//[email protected]/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/',
978+
href: '//[email protected]/everybody#to-the-limit'
994979
},
995980
};
996981

0 commit comments

Comments
 (0)