You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
'use strict';
|
|
var fails = require('../internals/fails');
|
|
var wellKnownSymbol = require('../internals/well-known-symbol');
|
|
var DESCRIPTORS = require('../internals/descriptors');
|
|
var IS_PURE = require('../internals/is-pure');
|
|
|
|
var ITERATOR = wellKnownSymbol('iterator');
|
|
|
|
module.exports = !fails(function () {
|
|
// eslint-disable-next-line unicorn/relative-url-style -- required for testing
|
|
var url = new URL('b?a=1&b=2&c=3', 'http://a');
|
|
var params = url.searchParams;
|
|
var params2 = new URLSearchParams('a=1&a=2&b=3');
|
|
var result = '';
|
|
url.pathname = 'c%20d';
|
|
params.forEach(function (value, key) {
|
|
params['delete']('b');
|
|
result += key + value;
|
|
});
|
|
params2['delete']('a', 2);
|
|
// `undefined` case is a Chromium 117 bug
|
|
// https://bugs.chromium.org/p/v8/issues/detail?id=14222
|
|
params2['delete']('b', undefined);
|
|
return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b')))
|
|
|| (!params.size && (IS_PURE || !DESCRIPTORS))
|
|
|| !params.sort
|
|
|| url.href !== 'http://a/c%20d?a=1&c=3'
|
|
|| params.get('c') !== '3'
|
|
|| String(new URLSearchParams('?a=1')) !== 'a=1'
|
|
|| !params[ITERATOR]
|
|
// throws in Edge
|
|
|| new URL('https://a@b').username !== 'a'
|
|
|| new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
|
|
// not punycoded in Edge
|
|
|| new URL('http://тест').host !== 'xn--e1aybc'
|
|
// not escaped in Chrome 62-
|
|
|| new URL('http://a#б').hash !== '#%D0%B1'
|
|
// fails in Chrome 66-
|
|
|| result !== 'a1c3'
|
|
// throws in Safari
|
|
|| new URL('http://x', undefined).host !== 'x';
|
|
});
|
|
|