0.1.0 • Published 2 years ago

@dashkite/url-router v0.1.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 years ago

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