From 7e67491049240fd9007864c9e79f01bcfc4e901a Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Wed, 26 Nov 2014 16:49:50 -0500 Subject: [PATCH] Leave out unnecessary trailing slash. --- backbone.js | 3 ++- test/router.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backbone.js b/backbone.js index b44ccaa8..765ff5c6 100644 --- a/backbone.js +++ b/backbone.js @@ -1481,7 +1481,8 @@ // If we've started off with a route from a `pushState`-enabled // browser, but we're currently in a browser that doesn't support it... if (!this._hasPushState && !this.atRoot()) { - this.location.replace(this.root + '#' + this.getPath()); + var root = this.root.slice(0, -1) || '/'; + this.location.replace(root + '#' + this.getPath()); // Return immediately as browser will do redirect to new url return true; diff --git a/test/router.js b/test/router.js index 407c332d..1fa22e63 100644 --- a/test/router.js +++ b/test/router.js @@ -565,7 +565,7 @@ Backbone.history.stop(); location.replace('http://example.com/root/x/y?a=b'); location.replace = function(url) { - strictEqual(url, '/root/#x/y?a=b'); + strictEqual(url, '/root#x/y?a=b'); }; Backbone.history = _.extend(new Backbone.History, { location: location, @@ -904,7 +904,7 @@ Backbone.history.stop(); location.replace('/root?foo=bar'); location.replace = function(url) { - strictEqual(url, '/root/#?foo=bar'); + strictEqual(url, '/root#?foo=bar'); }; Backbone.history = _.extend(new Backbone.History, { location: location,