diff --git a/lib/url.js b/lib/url.js index ade0007171ee48..a51e98ceb82a21 100644 --- a/lib/url.js +++ b/lib/url.js @@ -95,7 +95,11 @@ const slashedProtocol = new SafeSet([ 'gopher', 'gopher:', 'file', - 'file:' + 'file:', + 'ws', + 'ws:', + 'wss', + 'wss:' ]); const { CHAR_SPACE, diff --git a/test/parallel/test-url-parse-format.js b/test/parallel/test-url-parse-format.js index b318658febbaea..6d50be0e8b7c63 100644 --- a/test/parallel/test-url-parse-format.js +++ b/test/parallel/test-url-parse-format.js @@ -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/' } };