From 2555de7712b8caee213f1e7fe695273784e0907a Mon Sep 17 00:00:00 2001 From: n1474335 Date: Wed, 12 Jul 2017 12:49:10 +0000 Subject: [PATCH] Fixed bug in firefox where recipes containing an = character would not load from the URL --- src/core/Utils.js | 7 ++++++- src/web/App.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/Utils.js b/src/core/Utils.js index 8bfef0a8..6bcfced1 100755 --- a/src/core/Utils.js +++ b/src/core/Utils.js @@ -1000,9 +1000,14 @@ const Utils = { if (paramStr === "") return {}; // Cut off ? or # and split on & - const params = paramStr.substr(1).split("&"); + if (paramStr[0] === "?" || + paramStr[0] === "#") { + paramStr = paramStr.substr(1); + } + const params = paramStr.split("&"); const result = {}; + for (let i = 0; i < params.length; i++) { const param = params[i].split("="); if (param.length !== 2) { diff --git a/src/web/App.js b/src/web/App.js index fd11b85b..693e3efb 100755 --- a/src/web/App.js +++ b/src/web/App.js @@ -400,7 +400,12 @@ App.prototype.addFavourite = function(name) { */ App.prototype.loadURIParams = function() { // Load query string or hash from URI (depending on which is populated) - const params = window.location.search || window.location.hash; + // We prefer getting the hash by splitting the href rather than referencing + // location.hash as some browsers (Firefox) automatically URL decode it, + // which cause issues. + const params = window.location.search || + window.location.href.split("#")[1] || + window.location.hash; this.uriParams = Utils.parseURIParams(params); // Pause auto-bake while loading but don't modify `this.autoBake_`