This library provides a comprehensive polyfill for the native JavaScript `URLSearchParams` interface, allowing web developers to utilize its functionality in environments that lack full support, such as older browsers (e.g., IE8+) or specific Node.js versions. The current stable version is 8.2.5. The project appears to have a moderate release cadence, addressing bugs and adding features as needed, with major versions often introducing specific bug fixes or minor behavioral changes rather than massive overhauls. Key differentiators include its broad browser compatibility (down to IE8), full implementation of the MDN specification, and detection of existing `URLSearchParams` implementations to extend them rather than completely overwrite. It works seamlessly in both browser and Node.js environments, ensuring consistent behavior across different JavaScript runtimes.
npm install url-search-params-polyfillVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import the `URLSearchParams` polyfill and use various `URLSearchParams` methods like instantiation from strings or objects, `append`, `set`, `get`, `getAll`, `has`, `delete`, `sort`, and iteration using `for...of`.
Ensure your code does not rely on the previous error behavior for parameter names. Update to version 8.0.0 or later to use `Object.prototype` properties as parameter names without error.
Update to version 6.0.0 or later to correctly parse query strings with un-decodable `%` characters. Review any code that might have relied on the previous error-throwing behavior for such inputs.
Adjust your code to expect `keys()` and `values()` iterators to yield raw elements directly, not single-element arrays.
Manually add the `Content-Type: application/x-www-form-urlencoded; charset=UTF-8` header to your `fetch` requests when the `body` is an instance of `URLSearchParams` to ensure compatibility across all environments.
If working with React Native, test thoroughly after updating to 8.1.0 or later to ensure the polyfill behaves as expected and provides the necessary `URLSearchParams` functionality, as the detection mechanism was modified.
Upgrade `url-search-params-polyfill` to version 8.0.0 or higher. This version specifically addresses and fixes the bug allowing these property names to be used.
Update `url-search-params-polyfill` to version 6.0.0 or newer. This version includes a fix to handle such malformed URI components gracefully without throwing an error.
When creating a `fetch` request with a `URLSearchParams` body, explicitly set the `Content-Type` header to `'application/x-www-form-urlencoded; charset=UTF-8'`.
No dependency data recorded yet.