An open API service indexing awesome lists of open source software.

https://github.com/open-tech-foundation/route-matcher

A route pattern matcher using regular expressions.
https://github.com/open-tech-foundation/route-matcher

match params path regexp route

Last synced: 8 months ago
JSON representation

A route pattern matcher using regular expressions.

Awesome Lists containing this project

README

          

# Route Matcher

⚡ by [Open Tech World](https://open-tech-world.pages.dev/)

[![Build](https://github.com/open-tech-world/route-matcher/actions/workflows/build.yml/badge.svg)](https://github.com/open-tech-world/route-matcher/actions/workflows/build.yml)
[![npm bundle size (scoped version)](https://img.shields.io/bundlephobia/minzip/@open-tech-world/route-matcher/latest?label=Min%2BGZip)](https://bundlephobia.com/package/@open-tech-world/route-matcher)

> A route pattern matcher using regular expressions.

## Features

- Simple API
- Strict parsing (See parser rules)

- Supports named & unnamed parameters
- Supports custom regular experssions
- Parameters can be repeated or optional

## Live Tester

[https://route-matcher.pages.dev/tester](https://route-matcher.pages.dev/tester)

## Installation

```bash
# With npm
$ npm install @open-tech-world/route-matcher

# With yarn
$ yarn add @open-tech-world/route-matcher
```

## Usage

```ts
import { routeMatcher } from "@open-tech-world/route-matcher";

routeMatcher(route: string, path: string): RouteSegment[] | null;

// Eg: routeMatcher("/path/:param", "/path/value");
```

## Documentation

Please read the complete documentation at: [https://route-matcher.pages.dev/](https://route-matcher.pages.dev/)

## License

Copyright (c) [Thanga Ganapathy](https://github.com/Thanga-Ganapathy) ([MIT License](./LICENSE)).