Comparing version 0.1.21 to 0.1.22
@@ -209,6 +209,12 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
handlers: _handlers, | ||
urlComponents: url.split('/').slice(1), | ||
version: version | ||
version: version, | ||
regexRoute: false | ||
}; | ||
if (url instanceof RegExp) { | ||
r.regexRoute = true; | ||
} else { | ||
r.urlComponents = url.split('/').slice(1); | ||
} | ||
this.routes[version][method].push(r); | ||
@@ -228,3 +234,5 @@ this.routes.urls[version][url].push(r); | ||
if (!args[0] || typeof(args[0]) !== 'string') | ||
if (!args[0] || (typeof(args[0]) !== 'string' && | ||
!(args[0] instanceof RegExp))) | ||
throw new TypeError('argument 0 must be a string (version or url)'); | ||
@@ -253,3 +261,4 @@ | ||
if (!args[0] || typeof(args[0]) !== 'string') | ||
if (!args[0] || (typeof(args[0]) !== 'string' && | ||
!(args[0] instanceof RegExp))) | ||
throw new TypeError('argument 0 must be a string (version or url)'); | ||
@@ -278,3 +287,4 @@ | ||
if (!args[0] || typeof(args[0]) !== 'string') | ||
if (!args[0] || (typeof(args[0]) !== 'string' && | ||
!(args[0] instanceof RegExp))) | ||
throw new TypeError('argument 0 must be a string (version or url)'); | ||
@@ -303,3 +313,4 @@ | ||
if (!args[0] || typeof(args[0]) !== 'string') | ||
if (!args[0] || (typeof(args[0]) !== 'string' && | ||
!(args[0] instanceof RegExp))) | ||
throw new TypeError('argument 0 must be a string (version or url)'); | ||
@@ -328,3 +339,4 @@ | ||
if (!args[0] || typeof(args[0]) !== 'string') | ||
if (!args[0] || (typeof(args[0]) !== 'string' && | ||
!(args[0] instanceof RegExp))) | ||
throw new TypeError('argument 0 must be a string (version or url)'); | ||
@@ -331,0 +343,0 @@ |
@@ -64,4 +64,8 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
if (path === route.url) return {}; // there were no params in this case... | ||
if (path === route.url) | ||
return {}; // there were no params in this case... | ||
if (route.regexRoute) | ||
return route.url.exec(path); | ||
var params = route.urlComponents; | ||
@@ -68,0 +72,0 @@ var components = path.split('/').splice(1); |
{ | ||
"name": "restify", | ||
"description": "REST framework specifically meant for web service APIs", | ||
"version": "0.1.21", | ||
"version": "0.1.22", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -194,1 +194,21 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
}; | ||
exports.test_regex_route = function(test, assert) { | ||
var server = restify.createServer(); | ||
var socket = '/tmp/.' + uuid(); | ||
server.get(/^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/, _handler); | ||
server.listen(socket, function() { | ||
var opts = common.newOptions(socket, '/users/1..15'); | ||
http.request(opts, function(res) { | ||
common.checkResponse(assert, res); | ||
assert.equal(res.statusCode, 200); | ||
server.on('close', function() { | ||
test.finish(); | ||
}); | ||
server.close(); | ||
}).end(); | ||
}); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140711
2986