Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 904 Bytes

readme.md

File metadata and controls

49 lines (32 loc) · 904 Bytes

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