@dashkite/url-router

0.1.0 • Public • Published

URL Router

Match and destructure URLs templates:

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

Readme

Keywords

Package Sidebar

Install

npm i @dashkite/url-router

Weekly Downloads

0

Version

0.1.0

License

SEE LICENSE IN LICENSE.md

Unpacked Size

11.4 kB

Total Files

4

Last publish

Collaborators

  • dyoder
  • freeformflow