Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/briankopp/devalue-url
https://github.com/briankopp/devalue-url
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/briankopp/devalue-url
- Owner: BrianKopp
- Created: 2019-09-17T03:34:38.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T18:40:36.000Z (almost 2 years ago)
- Last Synced: 2024-10-24T12:13:18.460Z (23 days ago)
- Language: JavaScript
- Size: 51.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Devalue URL
[![Actions Status](https://github.com/briankopp/devalue-url/workflows/Build/badge.svg)](https://github.com/briankopp/devalue-url/actions)
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
```js
import { UrlDevaluer } from 'devalue-url';
const urlDevaluer = new UrlDevaluer();
urlDevaluer.devalueUrl('www.example.com/hello/123');
// www.example.com/hello/:intId
```### Custom Patterns
```js
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
```bash
git clone https://github.com/briankopp/devalue-url
cd devalue-url
npm install
npm run build
npm run test
```