route-peek
v0.0.10
Published
Library for route pathname parsing
Downloads
31
Readme
🧱 Route Peek
The library for creating and matching dynamic routes.
Documentation
👉 Read the Route Peek docs
Prerequisites
- Node.js version 18 or higher.
Installation
You can install route-peek
using the JavaScript package manager:
npm add route-peek
Usage
import { RouteMatcherBuilder } from 'route-peek';
const builder = new RouteMatcherBuilder();
builder.add('/');
builder.add('/users');
builder.add('/users/{id:[0-9]+}');
const matcher = builder.build();
const matchedRoutes = matcher.match('/users/1234');
console.log(matchedRoutes); // [{"path":"/users/1234","route":"/users/{id:[0-9]+}","params":{"id":"1234"},"score":154}]
License
MIT