Skip to content

Commit

Permalink
[fix] allow % in paths as encoded params are fine
Browse files Browse the repository at this point in the history
  • Loading branch information
Swaagie committed Dec 16, 2014
1 parent ac2fd0f commit 7fcf632
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/director/http/index.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/director/router.js
Expand Up @@ -84,7 +84,7 @@ function paramifyString(str, params, mod) {
}

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

Expand Down
2 changes: 1 addition & 1 deletion test/server/core/mount-test.js
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion test/server/core/path-test.js
Expand Up @@ -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')
Expand Down

0 comments on commit 7fcf632

Please sign in to comment.