Skip to content

pandastrike/panda-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Panda Router

Match and destructure URLs based on RFC 6570 for URL templates:

import {Router} from "panda-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 -S panda-router

Limitations

  • Does not parse all of RFC 6570. For example, the length specifier : is not implemented.

  • URL templates were not designed for destructuring, but rather expansion. Consequently, it's possible to define templates whose destructuring is not well-defined.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published