From f4fc6e57694e2d9351da91bb1b2e367a5c1160a8 Mon Sep 17 00:00:00 2001 From: Dao Hoang Son Date: Sat, 6 May 2017 00:08:39 +0700 Subject: [PATCH 1/2] Fix hash-mode replaceHash() when page has a --- src/history/hash.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/history/hash.js b/src/history/hash.js index 501f4844b..024397eac 100644 --- a/src/history/hash.js +++ b/src/history/hash.js @@ -90,8 +90,10 @@ function pushHash (path) { } function replaceHash (path) { - const i = window.location.href.indexOf('#') + const href = window.location.href + const i = href.indexOf('#') + window.location.replace( - window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path + window.location.href.slice(0, i >= 0 ? i : href.length) + '#' + path ) } From 97ec1d3cf93ff13da70420e3ed8fe059d898b0b8 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 16 Jun 2017 13:18:12 +0800 Subject: [PATCH 2/2] refactor --- src/history/hash.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/history/hash.js b/src/history/hash.js index 024397eac..a79319eda 100644 --- a/src/history/hash.js +++ b/src/history/hash.js @@ -92,8 +92,6 @@ function pushHash (path) { function replaceHash (path) { const href = window.location.href const i = href.indexOf('#') - - window.location.replace( - window.location.href.slice(0, i >= 0 ? i : href.length) + '#' + path - ) + const base = i >= 0 ? href.slice(0, i) : href + window.location.replace(`${base}#${path}`) }