From f4447b5ded95e724e9f733e7d88425b652558ae8 Mon Sep 17 00:00:00 2001 From: cj Date: Sun, 27 Jul 2014 08:59:27 -0500 Subject: [PATCH 1/3] removes trailing / --- app-router.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app-router.html b/app-router.html index 8e5a566..49fbf48 100644 --- a/app-router.html +++ b/app-router.html @@ -195,6 +195,9 @@ router.testRoute = function(routePath, urlPath) { // This algorithm tries to fail or succeed as quickly as possible for the most common cases. + // Remove trailing / + urlPath = urlPath.replace(/(\/$|\/\?)/, '') + // If the urlPath is an exact match or '*' then the route is a match if (routePath === urlPath || routePath === '*') { return true; @@ -313,4 +316,4 @@ prototype: router }); })(window, document); - \ No newline at end of file + From 2a94066041a006dd632eecdad7a08fb02d31d823 Mon Sep 17 00:00:00 2001 From: cj Date: Sun, 27 Jul 2014 09:01:26 -0500 Subject: [PATCH 2/3] too used to coffee :) --- app-router.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-router.html b/app-router.html index 49fbf48..2609d98 100644 --- a/app-router.html +++ b/app-router.html @@ -196,7 +196,7 @@ // This algorithm tries to fail or succeed as quickly as possible for the most common cases. // Remove trailing / - urlPath = urlPath.replace(/(\/$|\/\?)/, '') + urlPath = urlPath.replace(/(\/$|\/\?)/, ''); // If the urlPath is an exact match or '*' then the route is a match if (routePath === urlPath || routePath === '*') { From 08fa30bfcfa33683b3e6283c24f9762954f9b748 Mon Sep 17 00:00:00 2001 From: cj Date: Sun, 27 Jul 2014 09:55:51 -0500 Subject: [PATCH 3/3] do not remove if it's the root --- app-router.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app-router.html b/app-router.html index 2609d98..3f8b16c 100644 --- a/app-router.html +++ b/app-router.html @@ -195,8 +195,10 @@ router.testRoute = function(routePath, urlPath) { // This algorithm tries to fail or succeed as quickly as possible for the most common cases. - // Remove trailing / - urlPath = urlPath.replace(/(\/$|\/\?)/, ''); + // Remove trailing / unless it's the root + if(!urlPath.length == 1) { + urlPath = urlPath.replace(/(\/$|\/\?)/, ''); + } // If the urlPath is an exact match or '*' then the route is a match if (routePath === urlPath || routePath === '*') {