Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GH-146 Allow setting of regex flags even if path is a string
  • Loading branch information
Mark Cavage committed Jun 2, 2012
1 parent 93cb90b commit 8a901e8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/route.js
Expand Up @@ -176,7 +176,7 @@ function Route(options) {

self._url = url.parse(u).pathname;
self.pattern = '^';
self.flags = '';
self.flags = options.flags || '';
self.params = [];
self._url.split('/').forEach(function (fragment) {
if (!fragment.length)
Expand Down
1 change: 1 addition & 0 deletions lib/server.js
Expand Up @@ -418,6 +418,7 @@ Server.prototype._addRoute = function _addRoute(method, options, handlers) {
log: self.log,
method: method,
url: options.path || options.url,
flags: options.flags,
handlers: chain,
name: options.name,
version: options.version || self.version,
Expand Down
26 changes: 26 additions & 0 deletions test/server.test.js
Expand Up @@ -527,6 +527,32 @@ test('RegExp ok', function (t) {
});


test('path+flags ok', function (t) {
var server = restify.createServer({ dtrace: DTRACE, log: LOGGER });

server.get({path: '/foo', flags: 'i'}, function tester(req, res, next) {
res.send('hi there');
return next();
});

server.listen(PORT, function () {
var opts = {
hostname: 'localhost',
port: PORT,
path: '/FOO',
method: 'GET',
agent: false
};
http.request(opts, function (res) {
t.equal(res.statusCode, 200);
server.close(function () {
t.end();
});
}).end();
});
});


test('GH-56 streaming with filed (download)', function (t) {
var server = restify.createServer({ dtrace: DTRACE, log: LOGGER });

Expand Down

0 comments on commit 8a901e8

Please sign in to comment.