Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-02-21 04:47:25 +0300
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2020-03-24 17:29:25 +0300
commit43906746242a548b14263626bc63ee1e71dd1358 (patch)
tree316f0b9e71a9c8e247eefbef78818d5958c33340 /test
parent89692ff19b9a4ce03a7f4d4e6949fd2a0a2d6fd2 (diff)
url: handle quasi-WHATWG URLs in urlToOptions()
PR-URL: https://github.com/nodejs/node/pull/26226 Backport-PR-URL: https://github.com/nodejs/node/pull/32446 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-whatwg-url-custom-properties.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/test/parallel/test-whatwg-url-custom-properties.js b/test/parallel/test-whatwg-url-custom-properties.js
index 4a35215bc4a..045955e334d 100644
--- a/test/parallel/test-whatwg-url-custom-properties.js
+++ b/test/parallel/test-whatwg-url-custom-properties.js
@@ -133,8 +133,8 @@ assert.strictEqual(url.searchParams, oldParams);
// Test urlToOptions
{
- const opts =
- urlToOptions(new URL('http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test'));
+ const urlObj = new URL('http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test');
+ const opts = urlToOptions(urlObj);
assert.strictEqual(opts instanceof URL, false);
assert.strictEqual(opts.protocol, 'http:');
assert.strictEqual(opts.auth, 'user:pass');
@@ -147,6 +147,23 @@ assert.strictEqual(url.searchParams, oldParams);
const { hostname } = urlToOptions(new URL('http://[::1]:21'));
assert.strictEqual(hostname, '::1');
+
+ // If a WHATWG URL object is copied, it is possible that the resulting copy
+ // contains the Symbols that Node uses for brand checking, but not the data
+ // properties, which are getters. Verify that urlToOptions() can handle such
+ // a case.
+ const copiedUrlObj = Object.assign({}, urlObj);
+ const copiedOpts = urlToOptions(copiedUrlObj);
+ assert.strictEqual(copiedOpts instanceof URL, false);
+ assert.strictEqual(copiedOpts.protocol, undefined);
+ assert.strictEqual(copiedOpts.auth, undefined);
+ assert.strictEqual(copiedOpts.hostname, undefined);
+ assert.strictEqual(copiedOpts.port, NaN);
+ assert.strictEqual(copiedOpts.path, '');
+ assert.strictEqual(copiedOpts.pathname, undefined);
+ assert.strictEqual(copiedOpts.search, undefined);
+ assert.strictEqual(copiedOpts.hash, undefined);
+ assert.strictEqual(copiedOpts.href, undefined);
}
// Test special origins