Polyfill for URL and URLSearchParams. Totally following the implementation of Google Chrome.
$ npm i @lvchengbin/url --save
const { URL, URLSearchParams } = require( '@lvchengbin/url' );
import { URL, URLSearchParams } from '@lvchengbin/url';
If you want to use this library in browsers and to load it with <SCRIPT>
tag, you should use url.js, and if you want to use the library in browsers which do not support ES6 syntax, you should use url.bc.js instead.
<script src="./url.bc.js"></script>
<script>
var url = new JURL.URL( 'http://www.google.com/path?x=1&y=2' );
var params = new JURL.URLSearchParams( 'x=1&y=2' );
console.log( 'url', url );
console.log( 'params', params );
</script>