Skip to content

Commit

Permalink
support dot in named params
Browse files Browse the repository at this point in the history
  • Loading branch information
nrstott committed Oct 6, 2011
1 parent b9ef621 commit adfe1b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/router.js
Expand Up @@ -18,7 +18,7 @@ var
UPDATE: httpMethod.PUT,
DESTROY: httpMethod.DELETE
},
PATH_PARAMETER_REPLACEMENT = "([^\.\/\?]+)",
PATH_PARAMETER_REPLACEMENT = "([^\/\?]+)",
PATH_PARAMETERS = /:([\w\d]+)/g;

exports.bogartEvent = {
Expand Down
27 changes: 27 additions & 0 deletions test/router.test.js
Expand Up @@ -12,6 +12,16 @@ var bogart = require('../lib/bogart')
env: {}
};
};

function getMock(path) {
return {
headers: {},
pathInfo: path,
method: 'GET',
jsgi: { version: [0,3] },
env: {}
};
}

exports['test matches parameter'] = function(beforeExit) {
var
Expand Down Expand Up @@ -213,3 +223,20 @@ exports['test should have X-Powered-By Bogart header'] = function(beforeExit) {
assert.equal('Bogart', response.headers['X-Powered-By']);
});
};

exports['test matches a dot (".") as part of a named param'] = function(beforeExit) {
var router
, foo = null;

router = bogart.router();
router.get('/:foo/:bar', function(req) {
foo = req.params.foo;
});

router(getMock('/user@example.com/name'));

beforeExit(function() {
assert.isNotNull(foo, 'Named parameter should not be null');
assert.equal('user@example.com', foo);
});
};

0 comments on commit adfe1b3

Please sign in to comment.