diff --git a/router/router.js b/router/router.js index 446edd06..f6911de0 100644 --- a/router/router.js +++ b/router/router.js @@ -36,7 +36,7 @@ module.exports = function($window) { switch (type) { case "#": return normalize("hash").slice(prefix.length) case "?": return normalize("search").slice(prefix.length) + normalize("hash") - default: return normalize("pathname") + normalize("search") + normalize("hash") + default: return normalize("pathname").slice(prefix.length) + normalize("search") + normalize("hash") } } diff --git a/router/tests/test-defineRoutes.js b/router/tests/test-defineRoutes.js index bb6ba98e..85cb52db 100644 --- a/router/tests/test-defineRoutes.js +++ b/router/tests/test-defineRoutes.js @@ -5,7 +5,7 @@ var pushStateMock = require("../../test-utils/pushStateMock") var Router = require("../../router/router") o.spec("Router.defineRoutes", function() { - void ["#", "?", "", "#!", "?!"].forEach(function(prefix) { + void ["#", "?", "", "#!", "?!", "/foo"].forEach(function(prefix) { o.spec("using prefix `" + prefix + "`", function() { var $window, router, onRouteChange, onFail diff --git a/router/tests/test-getPath.js b/router/tests/test-getPath.js index fcfeaba5..70e2fb7b 100644 --- a/router/tests/test-getPath.js +++ b/router/tests/test-getPath.js @@ -5,7 +5,7 @@ var pushStateMock = require("../../test-utils/pushStateMock") var Router = require("../../router/router") o.spec("Router.getPath", function() { - void ["#", "?", "", "#!", "?!"].forEach(function(prefix) { + void ["#", "?", "", "#!", "?!", '/foo'].forEach(function(prefix) { o.spec("using prefix `" + prefix + "`", function() { var $window, router, onRouteChange, onFail diff --git a/router/tests/test-setPath.js b/router/tests/test-setPath.js index b85c97b2..a54db6f8 100644 --- a/router/tests/test-setPath.js +++ b/router/tests/test-setPath.js @@ -5,7 +5,7 @@ var pushStateMock = require("../../test-utils/pushStateMock") var Router = require("../../router/router") o.spec("Router.setPath", function() { - void ["#", "?", "", "#!", "?!"].forEach(function(prefix) { + void ["#", "?", "", "#!", "?!", "/foo"].forEach(function(prefix) { o.spec("using prefix `" + prefix + "`", function() { var $window, router, onRouteChange, onFail @@ -78,8 +78,10 @@ o.spec("Router.setPath", function() { router.defineRoutes({"/test": {data: 1}, "/other": {data: 2}}, onRouteChange, onFail) router.setPath("/other", null, {replace: false}) $window.history.back() - - o($window.location.href).equals("http://localhost/" + (prefix ? prefix + "/" : "") + "test") + + var slash = prefix[0] === "/" ? "" : "/" + + o($window.location.href).equals("http://localhost" + slash + (prefix ? prefix + "/" : "") + "test") }) }) })