Skip to content

george-aidonidis/safe-uri-path

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

safe-uri-path

CircleCI codecov npm version

A module to safely parse uri paths.

Why? 🤔

There are times that a string path will contain special characters. Imagine you are using a cat api and someone named a cat cat?*=my&cat. That is not a valid part of a url if someone was to include it. This library helps parsing correctly any uri paths 🎉

Install 🤘

yarn add --save safe-uri-path

Example

const safeUriPath = require('safe-uri-path');

const cat = 'cat';
// weird string with special characters
const weirdCat = 'cat?format=json';

const uriPath = safelyParseUri`/${cat}/${weirdCat}`;

Contributing

  1. Fork it (https://github.com/George-Aidonidis/safe-uri-path/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

MIT ©