node package manager

piggy-sanitize-uri

piggy-sanitize-uri NPM version Build Status

Purpose

Basic lib to sanitize uri with options.

Usage

import sanitizeUri from 'piggy-sanitize-uri'
 
let uri = '/my/path/?arg=value';
let sanitizedUri = sanitizeUri(uri);

With options:

import sanitizeUri from 'piggy-sanitize-uri'
 
let uri = '/my/path/?arg=value';
let options = {
  simpleChars: true,
  lowercase: true,
  endingslash: true,
  doubleshash: true
};
let sanitizedUri = sanitizeUri(uri);

Options

All options are simple boolean values to enable/disable the feature

  • simpleChars: keep only alnum, "-" and "/" chars in the path
  • lowercase: lowercase all the chars
  • endingslash: force an ending slash
  • doubleshash: remove double slash

Developer

Installing dev dependencies, you can edit the package source. Then run:

  • npm run dev-compile for babel transpilation
  • npm run dev-check for jshint check