https://github.com/qubitproducts/url-canon
Normalizes URL's to prevent duplicates that point to the same server resource
https://github.com/qubitproducts/url-canon
ceh cmh implement
Last synced: about 1 year ago
JSON representation
Normalizes URL's to prevent duplicates that point to the same server resource
- Host: GitHub
- URL: https://github.com/qubitproducts/url-canon
- Owner: QubitProducts
- Created: 2015-01-15T18:38:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-24T14:57:34.000Z (almost 10 years ago)
- Last Synced: 2025-01-31T22:49:29.971Z (over 1 year ago)
- Topics: ceh, cmh, implement
- Language: JavaScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 15
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Normalizes URL's to prevent duplicates that point to the same server resource.
```javascript
var urlCanon = require('url-canon')
urlCanon('http://www.google.com/?b=hey&a=yo')
// => returns 'http://www.google.com/?&a=yo&b=hey'
```
## Installation
```bash
npm install url-canon
```
## Features
* Sorts query parameters into alphabetical order
* Decodes needlessly percent-encoded ASCII
* Removes default ports for http/https
* Lowercases the protocol and hostname
* Removes trailing `#` and `?`
* Uppercases percent encoded bytes
## Compatibility
Tests pass in
* IE8+
* Chrome
* Firefox
* Opera
Does not support Node.js (as it uses an anchor element for parsing).
## Known issues
Internationalised URLs such as `http://見.香港/` are converted to punycode form in Chrome but not in Firefox and IE. Conversely punycode such as `http://xn--nw2a.xn--j6w193g/` is decoded automatically in Firefox and IE to `http://見.香港/`. It is very hard to standardise these URLs and they have not been handled.