-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
url: fix WHATWG URL host formatting error caused by port string #20493
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -388,7 +388,7 @@ Object.defineProperties(URL.prototype, { | |
}, options); | ||
const ctx = this[context]; | ||
var ret = ctx.scheme; | ||
if (ctx.host !== null) { | ||
if (ctx.hostname !== null) { | ||
ret += '//'; | ||
const has_username = ctx.username !== ''; | ||
const has_password = ctx.password !== ''; | ||
|
@@ -400,7 +400,9 @@ Object.defineProperties(URL.prototype, { | |
ret += '@'; | ||
} | ||
ret += options.unicode ? | ||
domainToUnicode(this.host) : this.host; | ||
domainToUnicode(this.hostname) : this.hostname; | ||
if (ctx.port !== '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The WHATWG URL API uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. > new url.URL("https://nodejs.org/en/")
URL {
href: 'https://nodejs.org/en/',
origin: 'https://nodejs.org',
protocol: 'https:',
username: '',
password: '',
host: 'nodejs.org',
hostname: 'nodejs.org',
port: '',
pathname: '/en/',
search: '',
searchParams: URLSearchParams {},
hash: '' } There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh my bad! This is the internal context... |
||
ret += `:${ctx.port}` | ||
} else if (ctx.scheme === 'file:') { | ||
ret += '//'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be
ctx.host !== null
. Thehostname
change only applies below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right,
URLContext
usesnull
: