Permalink
Browse files

Hacky way to do route matching

  • Loading branch information...
1 parent 9a89f08 commit dad949d1a6978bd200ce42e2568ef529449c810f @pquerna committed Mar 20, 2011
Showing with 24 additions and 2 deletions.
  1. +24 −2 lib/logmagic.js
View
@@ -95,8 +95,30 @@ function applyRoute(route, logger) {
}
}
-function routeMatch() {
- return False;
+function routeMatch(a, b) {
+ var as = a.split('.');
+ var bs = b.split('.');
+ var i = 0;
+
+ while(true) {
+ if (as.length < i || bs.length < i) {
+ break;
+ }
+ if (as[i] == bs[i]) {
+ if (as.length == i) {
+ return true;
+ }
+ i++;
+ continue;
+ }
+
+ if (as[i] == "*") {
+ return true;
+ }
+
+ break;
+ }
+ return false;
}
function applyRoutes(logger) {

0 comments on commit dad949d

Please sign in to comment.