@warren-bank/url
v3.1.4
Published
URL class library that does not perform any encoding or decoding
Downloads
125
Maintainers
Readme
jsURL
Javascript drop-in replacement URL class library for Node.js and the browser.
The important difference is that this library does not perform any encoding or decoding. Further reading: 1
Class Import
in Node.js:
npm install --save @warren-bank/url
const {URL, parse} = require('@warren-bank/url') { const gh = new URL('https://github.com/warren-bank') const qs = gh.searchParams gh.username = 'user' gh.password = 'pass' gh.port = 443 gh.hash = '#language-options' qs.set('tab', 'repositories') console.log('URL.href = ' + gh.href) console.log('parse(URL.href) = ' + JSON.stringify(parse(gh.href), null, 2)) console.log('parse(URL) = ' + JSON.stringify(parse(gh), null, 2)) console.log('parse(URL, true) = ' + JSON.stringify(parse(gh, true), null, 2)) }
in the browser:
<html> <head> <script src="https://cdn.jsdelivr.net/gh/warren-bank/js-url/es5-browser/jsURL.js"></script> <script> { // temporarily override global URL class with external implementation within scope of block const {URL, parse} = window.jsURL const gh = new URL('https://github.com/warren-bank') const qs = gh.searchParams gh.username = 'user' gh.password = 'pass' gh.port = 443 gh.hash = '#language-options' qs.set('tab', 'repositories') window.alert('URL.href = ' + gh.href) window.alert('parse(URL.href) = ' + JSON.stringify(parse(gh.href), null, 2)) window.alert('parse(URL) = ' + JSON.stringify(parse(gh), null, 2)) window.alert('parse(URL, true) = ' + JSON.stringify(parse(gh, true), null, 2)) } </script> </head> </html>
Limitations
The following methods are not implemented:
Legal
- copyright: Warren Bank
- license: GPL-2.0