devalue-url
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Devalue URL

Actions Status

Friendly, typed package used to strip values out of URLs, leaving only the URL template, as it might appear in an express app, for example.

Installing

npm install devalue-url

Usage

import { UrlDevaluer } from 'devalue-url';
const urlDevaluer = new UrlDevaluer();
urlDevaluer.devalueUrl('www.example.com/hello/123');
// www.example.com/hello/:intId

Custom Patterns

import { UrlDevaluer } from 'devalue-url';
const urlDevaluer = new UrlDevaluer({
    extraTemplatePatterns: {
        'abcReplacementName': RegExp('abc'),
        'defReplacementName': 'def'
    }
});
urlDevaluer.devalueUrl('www.example.com/hello/abc/def');
// www.example.com/hello/:abcReplacementName/:defReplacementName

Local Setup

git clone https://github.com/briankopp/devalue-url
cd devalue-url
npm install
npm run build
npm run test

Package Sidebar

Install

npm i devalue-url

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

11.8 kB

Total Files

11

Last publish

Collaborators

  • briankopp