Commit Graph

22 Commits

Author SHA1 Message Date
Buddy Sandidge
31bd5b6167 update email in package.json 2020-05-03 14:25:55 -07:00
Buddy Sandidge
77e3c8ea17 0.2.3 2020-05-03 13:40:28 -07:00
Buddy Sandidge
aa8a2c5e80 Merge branch 'master' of ssh://git.buddy.wtf/archive/routing-buddy 2020-05-03 13:31:33 -07:00
Buddy Sandidge
19a206bf1e update dependencies 2020-05-03 13:16:40 -07:00
Buddy Sandidge
5ec2a54150 Add semicolon lint rule 2019-10-01 20:16:30 -07:00
Buddy Sandidge
d5dcd25ed3 Update status 2019-10-01 19:31:59 -07:00
Buddy Sandidge
898b8f6d5a 0.2.2 2019-10-01 19:21:23 -07:00
Buddy Sandidge
74f1f119e1 Update outdated packages 2019-10-01 19:14:10 -07:00
Buddy Sandidge
ff7d7a252b Update dependencies to fix vulnerabilities 2019-01-14 22:43:33 -08:00
Buddy Sandidge
47c65ad9c7 Add test cases 2016-02-11 22:43:04 -08:00
Buddy Sandidge
2784f9d492 Add the ability to pass arguments to the route handler at route time
Arguments passed in to the route method at route time will be passed in
to the handler for that route.

var router = new Router()
router.add('/some/path' function (someParam) {
    // someParam would be 123
})
router.route('/some/path', {args: [123]})
2016-02-10 10:08:16 -08:00
Buddy Sandidge
2fbcab6dd2 Bump to version 0.1.2 2016-02-08 00:14:29 -08:00
Buddy Sandidge
79fb5395ab Correctly handle not found errors in partial routes
Take care of obvious case. A router with a route to '/foo/bar' but not
for '/foo', should give a not found error.
2016-02-08 00:10:25 -08:00
Buddy Sandidge
9da1eabbf2 Bump to 0.1.1 2016-02-07 22:24:18 -08:00
Buddy Sandidge
1797f41fc5 Update README 2016-02-07 22:23:10 -08:00
Buddy Sandidge
cc45cf24ee Bump to version 0.1.0 2016-02-07 22:14:25 -08:00
Buddy Sandidge
62e6469ec7 Add static isNotFound error checker to Router class
If used, it will allow the error message to change without inspecting
the error.message
2016-02-07 22:01:02 -08:00
Buddy Sandidge
f89bc55105 Refactor RouteNode → flatten for better readability 2016-02-07 21:24:50 -08:00
Buddy Sandidge
7c34964dff Add support for functions in router
Can add a function as to match a route. The function takes in a string
url segment and returns some value if the route matches or returns null
or undefined for no match.

Example usage:

function toInt(part) {
  var results = /^(\d+)$/.exec(part)
  return results ? parseInt(results[0], 10) : null
}

var router = new Router()
router.add(['/by/order', toInt], function (val) {
  // val === 123
})

router.route('/by/order/123')
2016-02-07 21:11:51 -08:00
Buddy Sandidge
a317aa86a8 Add support for regular expressions with capture groups
Router
    • add can take either a string or array
        • An array will check each item, for a string will be converted
          to an array

RouteNode
    • rename this._exact → this._children
        • exact matches will not have a '/' in a key because we split on
          the '/' character and RegExp will have a '/' in it
    • If an exact match can't be found first, check every regex on a node
        • Exact match will have preference over RegExp

utils
    • add forEach helper
    • add isArray and isRegExp checker
2016-02-07 20:28:32 -08:00
Buddy Sandidge
10371b7b1e Add Router that only matches exact strings with bootstrapped project
• Add linting with eslint
 • Add unit testing support with mocha with unit tests
 • Add Router class with support for only matching exact strings
 • Add RouteNode class for transversing all routes
2016-02-07 16:04:19 -08:00
Buddy Sandidge
b9d7eb3a7b Initial commit 2016-02-06 20:41:20 -08:00