flask-router-plus
Version:
Flask-inspired routing system for node and connect. Nice if you just need a routing system without depending on connect, or need routing middleware without all features provided by express.
30 lines (22 loc) • 574 B
JavaScript
// Generated by CoffeeScript 1.6.3
(function() {
var RegexExtractor;
RegexExtractor = (function() {
function RegexExtractor(regex) {
this.regex = regex;
}
RegexExtractor.prototype.extract = function(requestPath) {
var m;
m = this.regex.exec(requestPath);
if (!m) {
return null;
}
return m.slice(1);
};
RegexExtractor.prototype.test = function(requestPath) {
return this.extract(requestPath) !== null;
};
return RegexExtractor;
})();
module.exports = RegexExtractor;
}).call(this);