https://github.com/passy/node-dom-urls
A partial implementation of the W3C URL Spec Draft for Node
https://github.com/passy/node-dom-urls
Last synced: 11 months ago
JSON representation
A partial implementation of the W3C URL Spec Draft for Node
- Host: GitHub
- URL: https://github.com/passy/node-dom-urls
- Owner: passy
- License: mit
- Created: 2014-01-06T16:54:36.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-05-17T09:41:34.000Z (about 9 years ago)
- Last Synced: 2025-08-09T04:48:29.964Z (12 months ago)
- Language: JavaScript
- Size: 11.7 KB
- Stars: 15
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Node DOM URLs
=============
[](https://travis-ci.org/passy/node-dom-urls)
[](https://codeclimate.com/github/passy/node-dom-urls)
[](https://github.com/igrigorik/ga-beacon)
A partial implementation of the [W3C URL Spec Draft](https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html) for Node building on top of [URIjs](http://medialize.github.io/URI.js/).
If you find incompatibilities, please [report them](https://github.com/passy/node-dom-urls/issues). Error handling is currently very different from the spec.
Browser Polyfills
-----------------
- [Joshua Bell's Polyfill](https://github.com/inexorabletash/polyfill/blob/master/url.js)
- [Eric Arvidsson's Polyfill](https://github.com/arv/DOM-URL-Polyfill)
Installation
------------
`npm install dom-urls`
Example
-------
```js
var URL = require('dom-urls');
var url = new URL('relative', 'http://example.com/sub/');
url.protocol; // 'http:'
url.hostname; // 'example.com'
url.pathname; // '/sub/relative/'
url.host = 'example.net:8080';
url.port; // '8080'
```
Why `urijs` instead of `url`?
-----------------------------
I tried it first, but Node's own URL module doesn't propagate changes, so
changing the `host` doesn't affect the port and vice-versa and I didn't want to
reimplement all of that myself.