Giter Site home page Giter Site logo

byroads.js's Introduction

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.