Permalink
Browse files

[fix] allow % in paths as encoded params are fine

  • Loading branch information...
Swaagie committed Dec 16, 2014
1 parent ac2fd0f commit 7fcf63206af8c15b7a3514c99588e6bd013d8b5a
Showing with 4 additions and 4 deletions.
  1. +1 −1 lib/director/http/index.js
  2. +1 −1 lib/director/router.js
  3. +1 −1 test/server/core/mount-test.js
  4. +1 −1 test/server/core/path-test.js
@@ -124,7 +124,7 @@ Router.prototype.dispatch = function (req, res, callback) {
//
// Trap bad URLs from `decodeUri`
//
try { url = decodeURI(req.url.split('?', 1)[0]) }
try { url = decodeURI(req.url.split('?', 1)[0]); }
catch (ex) { url = null }

if (url && this._hasAccepts) {
@@ -84,7 +84,7 @@ function paramifyString(str, params, mod) {
}

return mod === str
? '([._a-zA-Z0-9-]+)'
? '([._a-zA-Z0-9-%]+)'
: mod;
}

@@ -71,7 +71,7 @@ vows.describe('director/core/mount').addBatch({
assertRoute(foobar, ['foo', 'jitsu', 'then', 'before'], router.routes);
assertRoute(foobazzbuzz, ['foo', 'bazz', 'buzz', 'on'], router.routes);
assertRoute(foostar, ['foo', 'jitsu', 'then', 'now', 'on'], router.routes);
assertRoute(foodog, ['foo', '([._a-zA-Z0-9-]+)', 'on'], router.routes);
assertRoute(foodog, ['foo', '([._a-zA-Z0-9-%]+)', 'on'], router.routes);
},

"should accept string path": function(router) {
@@ -34,7 +34,7 @@ vows.describe('director/core/path').addBatch({

assert.isFunction(router.routes.foo.on);
assert.isObject(router.routes.regions);
assert.isFunction(router.routes.regions['([._a-zA-Z0-9-]+)'].on);
assert.isFunction(router.routes.regions['([._a-zA-Z0-9-%]+)'].on);
},
"should dispatch the function correctly": function (router) {
router.dispatch('on', '/regions/newyork')

0 comments on commit 7fcf632

Please sign in to comment.