Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
url: add ws: and wss: to slashedProtocol set
Fix cases where the pathname is incorrectly parsed as `null`.
  • Loading branch information
lpinca committed Mar 27, 2019
commit 20fb558907eb6568b1b45bb9bdda3be53127f7e3
6 changes: 5 additions & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ const slashedProtocol = new SafeSet([
'gopher',
'gopher:',
'file',
'file:'
'file:',
'ws',
'ws:',
'wss',
'wss:'
]);
const {
CHAR_SPACE,
Expand Down
20 changes: 20 additions & 0 deletions test/parallel/test-url-parse-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,26 @@ const parseTests = {
pathname: "alert(1);a='@white-listed.com'",
path: "alert(1);a='@white-listed.com'",
href: "javascript:alert(1);a='@white-listed.com'"
},

'ws://www.example.com': {
protocol: 'ws:',
slashes: true,
hostname: 'www.example.com',
host: 'www.example.com',
pathname: '/',
path: '/',
href: 'ws://www.example.com/'
},

'wss://www.example.com': {
protocol: 'wss:',
slashes: true,
hostname: 'www.example.com',
host: 'www.example.com',
pathname: '/',
path: '/',
href: 'wss://www.example.com/'
}
};

Expand Down