Skip to content

Commit

Permalink
url: add ws: and wss: to slashedProtocol set
Browse files Browse the repository at this point in the history
Fix cases where the pathname is incorrectly parsed as `null`.

PR-URL: #26941
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
  • Loading branch information
lpinca authored and BethGriggs committed Apr 8, 2019
1 parent 28efecc commit 8798db3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit 8798db3

Please sign in to comment.