From 8ba0392cb7261e5c69c6957a9593d55945a95979 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Wed, 28 Mar 2012 13:55:19 +0300 Subject: [PATCH] Fix regressions caused by Firefox history fix. Removing the "#" from the beginning of history tokens was a mistake. Also the case of no previous history token was unhandled. --- template/app/History.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/template/app/History.js b/template/app/History.js index 99f98df2..edf5d3ac 100644 --- a/template/app/History.js +++ b/template/app/History.js @@ -95,8 +95,8 @@ Ext.define("Docs.History", { */ push: function(token, opts) { token = this.cleanUrl(token); - if (!/^!/.test(token)) { - token = "!"+token; + if (!/^#!?/.test(token)) { + token = "#!"+token; } // Firefox sometimes has %21 instead of !. // This happens with URL-s inside normal links on page. @@ -110,15 +110,16 @@ Ext.define("Docs.History", { // // To prevent this, check that previous equivalent entry isn't // equivalent to new one. - if (Ext.util.History.getToken().replace(/^%21/, "!") !== token) { + var prevToken = Ext.util.History.getToken() || ""; + if ("#"+prevToken.replace(/^%21/, "!") !== token) { Ext.util.History.add(token); } }, /** - * Given a URL, removes anything up to # (including #) + * Given a URL, removes anything before # */ cleanUrl: function(url) { - return url.replace(/^[^#]*#/, ''); + return url.replace(/^[^#]*#/, '#'); } }); -- GitLab