url: add ws: and wss: to slashedProtocol set

Fix cases where the pathname is incorrectly parsed as `null`.

PR-URL: https://github.com/nodejs/node/pull/26941
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
Luigi Pinca 2019-03-27 08:53:15 +01:00 committed by Michaël Zasso
parent 7a547098d5
commit 6a34b85b05
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2 changed files with 25 additions and 1 deletions

View File

@ -95,7 +95,11 @@ const slashedProtocol = new SafeSet([
'gopher',
'gopher:',
'file',
'file:'
'file:',
'ws',
'ws:',
'wss',
'wss:'
]);
const {
CHAR_SPACE,

View File

@ -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/'
}
};