diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2019-03-27 08:53:15 +0100 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2019-03-30 13:05:31 +0100 |
commit | 6a34b85b05d61d016a1ca5072c94f6b449ab0e06 (patch) | |
tree | 38701dc9489647b1d6016fba65318b2c16cbcaef | |
parent | 7a547098d5b13e14b8ad86145fd889fb18b7f3d4 (diff) | |
download | android-node-v8-6a34b85b05d61d016a1ca5072c94f6b449ab0e06.tar.gz android-node-v8-6a34b85b05d61d016a1ca5072c94f6b449ab0e06.tar.bz2 android-node-v8-6a34b85b05d61d016a1ca5072c94f6b449ab0e06.zip |
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>
-rw-r--r-- | lib/url.js | 6 | ||||
-rw-r--r-- | test/parallel/test-url-parse-format.js | 20 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/url.js b/lib/url.js index edc55c87aa..fba5558edb 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 d802b0f6dc..43c459d936 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/' } }; |