MES手机端
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.
 
 
 
 

43 lines
1.6 KiB

  1. 'use strict';
  2. var fails = require('../internals/fails');
  3. var wellKnownSymbol = require('../internals/well-known-symbol');
  4. var DESCRIPTORS = require('../internals/descriptors');
  5. var IS_PURE = require('../internals/is-pure');
  6. var ITERATOR = wellKnownSymbol('iterator');
  7. module.exports = !fails(function () {
  8. // eslint-disable-next-line unicorn/relative-url-style -- required for testing
  9. var url = new URL('b?a=1&b=2&c=3', 'https://a');
  10. var params = url.searchParams;
  11. var params2 = new URLSearchParams('a=1&a=2&b=3');
  12. var result = '';
  13. url.pathname = 'c%20d';
  14. params.forEach(function (value, key) {
  15. params['delete']('b');
  16. result += key + value;
  17. });
  18. params2['delete']('a', 2);
  19. // `undefined` case is a Chromium 117 bug
  20. // https://bugs.chromium.org/p/v8/issues/detail?id=14222
  21. params2['delete']('b', undefined);
  22. return (IS_PURE && (!url.toJSON || !params2.has('a', 1) || params2.has('a', 2) || !params2.has('a', undefined) || params2.has('b')))
  23. || (!params.size && (IS_PURE || !DESCRIPTORS))
  24. || !params.sort
  25. || url.href !== 'https://a/c%20d?a=1&c=3'
  26. || params.get('c') !== '3'
  27. || String(new URLSearchParams('?a=1')) !== 'a=1'
  28. || !params[ITERATOR]
  29. // throws in Edge
  30. || new URL('https://a@b').username !== 'a'
  31. || new URLSearchParams(new URLSearchParams('a=b')).get('a') !== 'b'
  32. // not punycoded in Edge
  33. || new URL('https://тест').host !== 'xn--e1aybc'
  34. // not escaped in Chrome 62-
  35. || new URL('https://a#б').hash !== '#%D0%B1'
  36. // fails in Chrome 66-
  37. || result !== 'a1c3'
  38. // throws in Safari
  39. || new URL('https://x', undefined).host !== 'x';
  40. });