Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multi-path-matcher

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-path-matcher - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

9

package.json
{
"name": "multi-path-matcher",
"version": "1.2.0",
"version": "1.3.0",
"type": "module",

@@ -10,4 +10,7 @@ "publishConfig": {

"module": "src/multi-path-matcher.mjs",
"description": "finds and decodes best matching path",
"keywords": [],
"description": "finds and decodes best matching path in a set of routes",
"keywords": [
"router",
"routing"
],
"contributors": [

@@ -14,0 +17,0 @@ {

@@ -17,6 +17,27 @@ [![npm](https://img.shields.io/npm/v/multi-path-matcher.svg)](https://www.npmjs.com/package/multi-path-matcher)

finds and decodes best matching path
finds and decodes best matching path in a set of routes
# usage
```js
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"); // undefined
matcher(compiled, "/a/b"); // routes[1]
matcher(compiled, "/a/b/c"); // routes[0]
matcher(compiled, "/d/value1/e"); // routes[3] { att1: "value1" }
matcher(compileds, "/d/value1/e/value2"); // routes[2] { att1: "value1", att2: "value2" }
matcher(macro, routes, "/"); // routes[4]
```
# API

@@ -28,11 +49,17 @@

- [CompiledRoutes](#compiledroutes)
- [Route](#route)
- [Properties](#properties)
- [Match](#match)
- [Properties](#properties-1)
- [compile](#compile)
- [Parameters](#parameters)
- [matcher](#matcher)
- [Parameters](#parameters-1)
- [multi-path-matcher](#multi-path-matcher)
- [usage](#usage)
- [API](#api)
- [Table of Contents](#table-of-contents)
- [CompiledRoutes](#compiledroutes)
- [Route](#route)
- [Properties](#properties)
- [Match](#match)
- [Properties](#properties-1)
- [compile](#compile)
- [Parameters](#parameters)
- [matcher](#matcher)
- [Parameters](#parameters-1)
- [install](#install)
- [license](#license)

@@ -63,8 +90,8 @@ ## CompiledRoutes

- `route` **[Route](#route)**
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `route` **[Route](#route)** as given to the compiler
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** extracted from the path
## compile
compile a set of routes
Compile a set of routes

@@ -75,6 +102,8 @@ ### Parameters

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
Returns **[CompiledRoutes](#compiledroutes)**
## matcher
Find best match for a given path
### Parameters

@@ -81,0 +110,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc