UNPKG

@dashkite/url-router

Version:

Match and destructure URLs based on URL templates

30 lines (20 loc) 547 B
# URL Router Match and destructure URLs templates: ```coffee import { Router } from "@dashkite/url-router" router = Router.create() router.add template: "/blog/posts/{key}" data: pages.view router.add template: "/blog/posts/{key}?{token}" data: pages.edit match = router.match "/blog/posts/my-first-post?token=miukhuJIguMjq5rXZzslww" assert.equal true, match? assert.equal match.data, pages.edit assert.deepEqual match.bindings, key: "my-first-post" token: "miukhuJIguMjq5rXZzslww" ``` ## Install `npm i @dashkite/url-router`