Skip to content
Url pattern matching (lexer) that return result(s) based the order they were added or a overriding priority.
JavaScript CSS HTML
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
src
tests
.gitignore
.jshintrc
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
bower.json
build.js
package.json

README.md

Build Status

byroads

Url pattern matching (lexer) that return result(s) based the order they were added or a overriding priority.

Code mostly extracted from Crossroads.js, thanks!

TODO:

  • See if https://github.com/snd/url-pattern would be a better option... and if it works on most browsers.
  • Make the tests work
  • Switch from jasmine to mocha
  • Build with gulp
  • Add tests result on github page

Examples (taken from the Crossroads.js website)

String rule with param: '/news/{id}'

match '/news/123' passing "123" as param to handler

String rule with optional param: '/foo/{id}/:slug:'

match '/foo/123/bar' passing "123" and "bar" as param match '/foo/45' passing 45 as param (slug is optional)

RegExp rule: /^\/lorem\/([a-z]+)$/

match '/lorem/ipsum' passing "ipsum" as param to handler note the capturing group around segment

String rule with rest segments: '/foo/{id*}/edit'

match '/foo/123/edit' passing "123" as argument match '/foo/45/asd/123/edit' passing "45/asd/123" as argument

Query String: 'foo.php{?query}'

match 'foo.php?lorem=ipsum&dolor=amet'

Something went wrong with that request. Please try again.