1.0.3 • Published 2 years ago

micro-match v1.0.3

Weekly downloads
50
License
-
Repository
github
Last release
2 years ago

micro match

A simple url matching utility for micro.

Installation

To install micro match, simply run the following command in your terminal of choice.

npm install -g micro-match

Once you have installed micro match, simply include it in your project like so...

const { match, test } = require('micro-match');

Usage

Match

The match method allows you to match a route binding to it's real world counterpart and return it's bindings.

const {id} = match('/users/:id', '/users/1');

Parameters are defined as a comma followed by an alias to bind it's value to.

You can also create optional parameters by attaching a ? suffix. This will allow both /users and /users/1 to be matched.

Now you will be able to access the id parameter with the value of 1 and handle it however ever you like.

Test

The test method allows you check if the pattern matches the given url.

test('/users/:id', '/users/1');

Changes

Details for each release are documented in the release notes.

License

This utility is licensed under MIT, see LICENSE.md for details.

1.0.3

2 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

6 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago