url-search-params

Simple polyfill for URLSearchParams standard

now available as @ungap/url-search-params
Last updated 2 years ago by webreflection .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install url-search-params 
SYNC missed versions from official npm registry.

url-search-params

build status CDNJS version donate

This is a polyfill for the URLSearchParams API.

It is possible to simply include build/url-search-params.js or grab it via npm.

npm install url-search-params

The function is exported directly.

var URLSearchParams = require('url-search-params');

MIT Style License

iOS 10 + other platforms bug

In case you'd like to replace the broken global native constructor, you can check some well known issue before including this polyfill on your project/page.

<script>
try { if (new URLSearchParams('q=%2B').get('q') !== '+') throw {}; }
catch (error) {
  window.URLSearchParams = void 0;
  document.write('<script src="/js/url-search-params.js"><'+'/script>');
}
</script>

About HTMLAnchorElement.prototype.searchParams

This property is already implemented in Firefox and polyfilled here only for browsers that exposes getters and setters through the HTMLAnchorElement.prototype.

In order to know if such property is supported, you must do the check as such:

if ('searchParams' in HTMLAnchorElement.prototype) {
  // polyfill for <a> links supported
}

If you do this check instead:

if (HTMLAnchorElement.prototype.searchParams) {
  // throws a TypeError
}

this polyfill will reflect native behavior, throwing a type error due access to a property in a non instance of HTMLAnchorElement.

Nothing new to learn here, just a reminder.

Current Tags

  • 1.1.0                                ...           latest (2 years ago)

20 Versions

  • 1.1.0 [deprecated]           ...           2 years ago
  • 1.0.2 [deprecated]           ...           2 years ago
  • 1.0.1 [deprecated]           ...           2 years ago
  • 1.0.0 [deprecated]           ...           2 years ago
  • 0.10.2 [deprecated]           ...           2 years ago
  • 0.10.1 [deprecated]           ...           2 years ago
  • 0.10.0 [deprecated]           ...           3 years ago
  • 0.7.1 [deprecated]           ...           3 years ago
  • 0.9.0 [deprecated]           ...           3 years ago
  • 0.8.0 [deprecated]           ...           3 years ago
  • 0.7.0 [deprecated]           ...           3 years ago
  • 0.6.1 [deprecated]           ...           4 years ago
  • 0.6.0 [deprecated]           ...           4 years ago
  • 0.5.0 [deprecated]           ...           4 years ago
  • 0.4.0 [deprecated]           ...           4 years ago
  • 0.3.0 [deprecated]           ...           4 years ago
  • 0.2.0 [deprecated]           ...           5 years ago
  • 0.1.0 [deprecated]           ...           5 years ago
  • 0.0.1 [deprecated]           ...           5 years ago
  • 0.0.0 [deprecated]           ...           5 years ago
Maintainers (1)
Downloads
Today 3
This Week 465
This Month 670
Last Day 40
Last Week 370
Last Month 1,753
Dependencies (0)
None
Dev Dependencies (4)
Dependents (199)

Copyright 2014 - 2017 © taobao.org |