Skip to content

bcombinator/composable-normalize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 🔥

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?

About

Experiment to normalize URLs w/ functional programming

Resources

License

Stars

Watchers

Forks

Packages

No packages published