# url-search-params

> Simple polyfill for URLSearchParams standard

Latest version **1.1.0** (published 2018-09-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install url-search-params
pnpm add url-search-params
yarn add url-search-params
bun add url-search-params
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-09-10 |
| First published | 2015-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/url-search-params) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 46.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 762 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | DOM, URLSearchParams, polyfill, shim |

## Links

- npm: https://www.npmjs.com/package/url-search-params
- Repository: https://github.com/WebReflection/url-search-params
- Issues: https://github.com/WebReflection/url-search-params/issues
- npm.io page: https://npm.io/package/url-search-params

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-09-10
- 1.0.2 — 2018-07-03
- 1.0.1 — 2018-07-03
- 1.0.0 — 2018-07-03
- 0.10.2 — 2018-07-03
- 0.10.1 — 2018-07-03
- 0.10.0 — 2017-07-28
- 0.7.1 — 2017-07-23
- 0.9.0 — 2017-05-17
- 0.8.0 — 2017-05-02
- 0.7.0 — 2017-03-17
- 0.6.1 — 2016-09-14
- 0.6.0 — 2016-09-06
- 0.5.0 — 2016-03-16
- 0.4.0 — 2016-02-19
- … 5 more at https://npm.io/package/url-search-params/versions

## README

url-search-params
=================

[![build status](https://secure.travis-ci.org/WebReflection/url-search-params.svg)](http://travis-ci.org/WebReflection/url-search-params) [![CDNJS version](https://img.shields.io/cdnjs/v/url-search-params.svg)](https://cdnjs.com/libraries/url-search-params) [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000&style=flat)](https://github.com/WebReflection/donate)

This is a polyfill for the [URLSearchParams API](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams).

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

```
npm install url-search-params
```

The function is exported directly.
```js
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.

```html
<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:
```js
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](http://webreflection.blogspot.co.uk/2011/08/please-stop-reassigning-for-no-reason.html).

---
_Source: https://npm.io/package/url-search-params · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
