-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
url: detect hostname more reliably in url.parse()
Based on existing tests and code comments, url.parse() is expected to treat any URL containing user@host as having a hostname. However, it turns out this behavior relies on the URL having a hash which is surprising, to put it mildly. Detect the host even without the hash. PR-URL: #41031 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Myles Borins <[email protected]>
- Loading branch information
1 parent
de1748a
commit db77780
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -946,7 +946,37 @@ const parseTests = { | |
pathname: '/', | ||
path: '/', | ||
href: 'wss://www.example.com/' | ||
} | ||
}, | ||
|
||
'//[email protected]/everybody-to-the-limit': { | ||
protocol: null, | ||
slashes: true, | ||
auth: 'fhqwhgads', | ||
host: 'example.com', | ||
port: null, | ||
hostname: 'example.com', | ||
hash: null, | ||
search: null, | ||
query: null, | ||
pathname: '/everybody-to-the-limit', | ||
path: '/everybody-to-the-limit', | ||
href: '//[email protected]/everybody-to-the-limit' | ||
}, | ||
|
||
'//[email protected]/everybody#to-the-limit': { | ||
protocol: null, | ||
slashes: true, | ||
auth: 'fhqwhgads', | ||
host: 'example.com', | ||
port: null, | ||
hostname: 'example.com', | ||
hash: '#to-the-limit', | ||
search: null, | ||
query: null, | ||
pathname: '/everybody', | ||
path: '/everybody', | ||
href: '//[email protected]/everybody#to-the-limit' | ||
}, | ||
}; | ||
|
||
for (const u in parseTests) { | ||
|