forked from cowboy/javascript-route-matcher
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Renamed some stuff, like the name of the project. And the function. A…
…nd wrote some very rudimentary docs. Etc.
- Loading branch information
Showing
4 changed files
with
48 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
# Plugin? | ||
# JavaScript Basic Route Matcher | ||
A simple route matching utility. Intended to be included as part of a larger routing library. | ||
|
||
JUST SOME STUFF MAYBE FOR BBQ MAYBE NOT | ||
## Sample Usage | ||
```javascript | ||
// You can use routeMatcher to match just once. | ||
routeMatcher("search/:query/p:page", "search/boston/p20"); // {query: "boston", page: "20"} | ||
|
||
WORK IN PROGRESS DONT USE YET KTHX | ||
// Or you can use routeMatcher to create a reusable route matching function. | ||
var matchRoute = routeMatcher("search/:query/p:page"); | ||
matchRoute("search/gonna-fail") // null | ||
matchRoute("search/cowboy/p5") // {query: "cowboy", page: "5"} | ||
matchRoute("search/gnarf/p10") // {query: "gnarf", page: "10"} | ||
|
||
NOT EVEN USING JQUERY YET MAYBE IT NEVER WILL | ||
// You can pass in a RegExp route as well. | ||
var matchRoute = routeMatcher(/^users?(?:\/(\d+)(?:\.\.(\d+))?)?/); | ||
matchRoute("gonna-fail" // null (no match) | ||
matchRoute("user") // ["user", undefined, undefined] | ||
matchRoute("users") // ["users", undefined, undefined] | ||
matchRoute("user/123"); // ["user/123", "123", undefined] | ||
matchRoute("user/123..456"); // ["user/123..456", "123", "456"] | ||
``` | ||
I LOVE COOKIES | ||
## Documentation | ||
Look at the [unit tests](unit/ba-routematcher.js). | ||
## Release History | ||
Nothing official yet... | ||
## License | ||
Copyright (c) 2011 "Cowboy" Ben Alman | ||
Dual licensed under the MIT and GPL licenses. | ||
<http://benalman.com/about/license/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters