url-polyfill

Polyfill URL and URLSearchParams

MIT 29 个版本
安装
npm install url-polyfill
yarn add url-polyfill
pnpm add url-polyfill
bun add url-polyfill
README

Polyfill URL and URLSearchParams to match last WHATWG specifications

Compliant in most of the use cases but not at 100% (like unicode chars, punycodes, etc...)

Tested on IE 10+

Install

npm i url-polyfill --save

Currently supported

window.URL

Documentation: https://developer.mozilla.org/en-US/docs/Web/API/URL

Supported : 'hash', 'host', 'hostname', 'href', 'port', 'protocol', 'search', 'toString', 'pathname', 'origin', 'searchParams'

Example:

const url = new URL('https://www.example.com:8080/?fr=yset_ie_syc_oracle&type=orcl_hpset#page0');
  • hash: "page0"
  • host: "www.example.com:8080"
  • hostname: "www.example.com"
  • href: "https://www.example.com:8080/?fr=yset_ie_syc_oracle&type=orcl_hpset#page0"
  • origin: "https://www.example.com:8080"
  • pathname: "/"
  • port: "8080"
  • protocol: "https:"
  • search: "?fr=yset_ie_syc_oracle&type=orcl_hpset"
  • searchParams: URLSearchParams (see next)
window.URLSearchParams

Documentation: https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

Supported : 'append', 'delete', 'get', 'getAll', 'has', 'set', 'forEach', 'keys', 'values', 'entries', 'toString', 'Symbol.iterator'

Example:

const url = new URL('https://www.example.com/?fr=yset_ie_syc_oracle&type=orcl_hpset#page0');
url.searchParams.append('page', 0);
console.log(url.toString()); // print: "https://www.example.com/?fr=yset_ie_syc_oracle&type=orcl_hpset&page=0#page0"
版本列表
1.1.14 2025-09-08
1.1.13 2025-02-08
1.1.12 2020-10-31
1.1.11 2020-10-14
1.1.10 2020-07-20
1.1.9 2020-05-13
1.1.8 2020-01-29
1.1.7 2019-07-14
1.1.6 2019-07-09
1.1.5 2019-03-05
1.1.3 2018-11-30
1.1.2 2018-11-28
1.1.1 2018-11-27
1.1.0 2018-09-03
1.0.14 2018-08-09
1.0.13 2018-04-04
1.0.12 2018-03-28
1.0.11 2018-01-18
1.0.10 2017-12-14
1.0.9 2017-12-12
1.0.8 2017-09-26
1.0.7 2017-07-27
1.0.6 2017-06-01
1.0.5 2017-05-02
1.0.4 2017-04-19
1.0.3 2017-04-03
1.0.2 2017-04-03
1.0.1 2017-03-28
1.0.0 2017-03-20