devalue-url
v0.1.1
Published
A small package to strip values out of a url to get its template
Downloads
4
Maintainers
Readme
Devalue URL
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