Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "app-lite", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"stability": 1, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,3 +9,3 @@ | ||
var fn, re | ||
var fn | ||
, fnStr = "" | ||
@@ -24,7 +24,6 @@ , reStr = "" | ||
var app, route | ||
, match = re.exec(req.url) | ||
, match = fn(req.url, req.params || (req.params = {})) | ||
if (match) { | ||
route = fn(req.params || (req.params = {}), match) | ||
app = routes[route] | ||
app = routes[match] | ||
app(req, res, next) | ||
@@ -39,14 +38,16 @@ } else { | ||
var startLen = groupsCount++ | ||
, a = ["r='" + route + "'"] | ||
, params = "," | ||
, _re = route.replace(parseRe, function(_, key) { | ||
return key ? | ||
a.push("o['" + key + "']=a[" + (groupsCount++) + "]") && "([^/]+?)" : | ||
(params += "o['" + key + "']=u[" + (groupsCount++) + "],") && "([^/]+?)" : | ||
escapeRegExp(_) | ||
}) | ||
fnStr += (fnStr ? "||" : "") + "(" + a + ")" | ||
fnStr += "u[" + startLen + "]?(" + params.slice(1) + "'" + route + "'):" | ||
reStr += (reStr ? "|" : "") + "(" + _re + ")" | ||
fn = new Function("o,a,r", "return a&&(" + fnStr + "),r") | ||
re = new RegExp("^\\/?(?:" + reStr + ")[\\/\\s]*$") | ||
fn = new Function( | ||
"u,o,r", | ||
"return (u=/^\\/?(?:" + reStr + ")[\\/\\s]*$/.exec(u))?(" + fnStr + "r):r" | ||
) | ||
} | ||
@@ -53,0 +54,0 @@ |
17220
10
540