12345678910111213141516171819202122232425262728 |
- 'use strict';
- var defineBuiltIn = require('../internals/define-built-in');
- var uncurryThis = require('../internals/function-uncurry-this');
- var toString = require('../internals/to-string');
- var validateArgumentsLength = require('../internals/validate-arguments-length');
- var $URLSearchParams = URLSearchParams;
- var URLSearchParamsPrototype = $URLSearchParams.prototype;
- var getAll = uncurryThis(URLSearchParamsPrototype.getAll);
- var $has = uncurryThis(URLSearchParamsPrototype.has);
- var params = new $URLSearchParams('a=1');
- // `undefined` case is a Chromium 117 bug
- // https://bugs.chromium.org/p/v8/issues/detail?id=14222
- if (params.has('a', 2) || !params.has('a', undefined)) {
- defineBuiltIn(URLSearchParamsPrototype, 'has', function has(name /* , value */) {
- var length = arguments.length;
- var $value = length < 2 ? undefined : arguments[1];
- if (length && $value === undefined) return $has(this, name);
- var values = getAll(this, name); // also validates `this`
- validateArgumentsLength(length, 1);
- var value = toString($value);
- var index = 0;
- while (index < values.length) {
- if (values[index++] === value) return true;
- } return false;
- }, { enumerable: true, unsafe: true });
- }
|