multi-path-matcher
finds and decodes best matching path in a set of routes
usage
import { compile, matcher } from "multi-path-matcher";
const routes = [
{ path: "/a/b/c" },
{ path: "/a/b" },
{ path: "/d/:att1/e/:att2" },
{ path: "/d/:att1/e" },
{ path: "/" }
];
const compiled = compile(routes);
matcher(compiled "/a");
matcher(compiled, "/a/b");
matcher(compiled, "/a/b/c");
matcher(compiled, "/d/value1/e");
matcher(compileds, "/d/value1/e/value2");
matcher(macro, routes, "/");
API
Table of Contents
CompiledRoutes
Result of the routes compilation
Type: Object
Route
one single route
Type: Object
Properties
Match
result of a match
Type: Object
Properties
route
Route as given to the compilerparams
Object extracted from the path
compile
Compile a set of routes
Parameters
Returns CompiledRoutes
matcher
Find best match for a given path
Parameters
Returns Match match
install
With npm do:
npm install multi-path-matcher
license
BSD-2-Clause