From 7324006d8cd1644550e2ea7cc09406d876ef6945 Mon Sep 17 00:00:00 2001 From: Elian Ibaj Date: Sun, 1 Apr 2018 14:00:10 +0200 Subject: [PATCH] Fix hash replacement redirect --- modules/createHashHistory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/createHashHistory.js b/modules/createHashHistory.js index bce546f87..055b16610 100644 --- a/modules/createHashHistory.js +++ b/modules/createHashHistory.js @@ -45,11 +45,11 @@ const getHashPath = () => { const pushHashPath = path => (window.location.hash = path); const replaceHashPath = path => { - const hashIndex = window.location.href.indexOf("#"); + let href = window.location.href; + const hashIndex = href.indexOf("#"); + if (hashIndex !== -1) href = href.slice(0, hashIndex); - window.location.replace( - window.location.href.slice(0, hashIndex >= 0 ? hashIndex : 0) + "#" + path - ); + window.location.replace(href + "#" + path); }; const createHashHistory = (props = {}) => {