2.0.3 • Published 8 years ago

composable-normalize v2.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

npm.io

npm.io API stability npm version JavaScript Style Guide

composable-normalize

Experiment to normalize URLs w/ functional programming

Install

npm i --save-dev composable-normalize

Usage

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 :fire:

import {normalize, compose} from 'composable-normalize'

compose(str => `${str}bar`, normalize)('HTTP://github.com////foo/')
// => 'http://github.com/foo/bar'

Current Features

  • Dedupe slashes
  • Dedupe dots
  • Decode
  • Lowercase scheme
  • Remove default http/https ports
  • Adds trailing slash

Todos

  • Add Tests
  • Publish to npm
  • Add Options?
2.0.3

8 years ago

2.0.2

8 years ago

2.0.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago