Experiment to normalize URLs w/ functional programming
npm i --save-dev composable-normalize
import {normalize} from 'composable-normalize'
normalize('HTTP://www.Github.com/')
//=> 'http://www.github.com/'
normalize('http://www.github.com/../a/b/../c/./d')
// => 'http://www.github.com/a/b/c/d/'
normalize('http://www.github.com:80/bar')
// => 'http://www.github.com/bar/'
normalize('http://www.github.com/%7Eusername/')
// => 'http://www.github.com/~username/'
also as a bonus you can do functional composition right to left 🔥
import {normalize, compose} from 'composable-normalize'
compose(str => `${str}bar`, normalize)('HTTP://github.com////foo/')
// => 'http://github.com/foo/bar'
- Dedupe slashes
- Dedupe dots
- Decode
- Lowercase scheme
- Remove default http/https ports
- Adds trailing slash
- Add Tests
- Publish to npm
- Add Options?