Skip to content

Commit 8798db3

Browse files
lpincaBethGriggs
authored andcommittedApr 8, 2019
url: add ws: and wss: to slashedProtocol set
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>
1 parent 28efecc commit 8798db3

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎lib/url.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ const slashedProtocol = new SafeSet([
9595
'gopher',
9696
'gopher:',
9797
'file',
98-
'file:'
98+
'file:',
99+
'ws',
100+
'ws:',
101+
'wss',
102+
'wss:'
99103
]);
100104
const {
101105
CHAR_SPACE,

‎test/parallel/test-url-parse-format.js

+20
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,26 @@ const parseTests = {
923923
pathname: "alert(1);a='@white-listed.com'",
924924
path: "alert(1);a='@white-listed.com'",
925925
href: "javascript:alert(1);a='@white-listed.com'"
926+
},
927+
928+
'ws://www.example.com': {
929+
protocol: 'ws:',
930+
slashes: true,
931+
hostname: 'www.example.com',
932+
host: 'www.example.com',
933+
pathname: '/',
934+
path: '/',
935+
href: 'ws://www.example.com/'
936+
},
937+
938+
'wss://www.example.com': {
939+
protocol: 'wss:',
940+
slashes: true,
941+
hostname: 'www.example.com',
942+
host: 'www.example.com',
943+
pathname: '/',
944+
path: '/',
945+
href: 'wss://www.example.com/'
926946
}
927947
};
928948

0 commit comments

Comments
 (0)
Please sign in to comment.