Skip to content

jt3k/url-checker

Repository files navigation

url-checker Build Status

Tiny, light-weight JavaScript routing with zero dependencies.

Usage

const urlChecker = require('url-checker'); // not now in npm, but u cat copy code from index.js is very-lightweight!

urlChecker(
	{
		'/a/b-{c}-d-{e}':  vars => console.log(vars),
		'/about':          vars => console.log(vars),
	},
	'/a/b-lalala-d-lololo'
);

// prints   {c: 'lalala', e: 'lololo'}

API

urlChecker(routes, url)

routes

Type: object

{
	'/category': variablesFromUrl => {},
	'/category/page': variablesFromUrl => {},
	'/category/page-{pageNumber}': variablesFromUrl => { /* here variablesFromUrl.pageNumber is 31337 */ },
}

url

Type: string

/category/page-31337

License

MIT © Andrey Gurtovoy

About

Helps to check urls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published