]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/router.js
Log failures to match a route for the initial path
[rails.git] / app / assets / javascripts / router.js
index 5c444d46cccfc9bd20bf9ecedad65760ca3fa648..0d57b80d488c3d56e291272b2ba9070ac0bd5508 100644 (file)
@@ -91,7 +91,7 @@ OSM.Router = function(map, rts) {
     }
   };
 
-  var currentPath = window.location.pathname.replace(/\/$/, "") + window.location.search,
+  var currentPath = window.location.pathname.replace(/(.)\/$/, '$1') + window.location.search,
     currentRoute = routes.recognize(currentPath),
     currentHash = location.hash || OSM.formatHash(map);
 
@@ -169,8 +169,12 @@ OSM.Router = function(map, rts) {
   };
 
   router.load = function() {
-    var loadState = currentRoute.run('load', currentPath);
-    router.stateChange(loadState || {});
+    if (currentRoute) {
+      var loadState = currentRoute.run('load', currentPath);
+      router.stateChange(loadState || {});
+    } else {
+      console.log("Unable to match route for: " + currentPath);
+    }
   };
 
   map.on('moveend baselayerchange overlaylayerchange', router.updateHash);