diff --git a/src/history/hash.js b/src/history/hash.js index 62b9a3472..010c610cf 100644 --- a/src/history/hash.js +++ b/src/history/hash.js @@ -107,27 +107,15 @@ function ensureSlash (): boolean { } export function getHash (): string { - // We can't use window.location.hash here because it's not - // consistent across browsers - Firefox will pre-decode it! + // We need to get the raw hash to keep consistent behavior with routes + // `fullPath` using encoded path. The params are decoded later in the + // matcher. let href = window.location.href const index = href.indexOf('#') // empty path if (index < 0) return '' href = href.slice(index + 1) - // decode the hash but not the search or hash - // as search(query) is already decoded - // https://github.com/vuejs/vue-router/issues/2708 - const searchIndex = href.indexOf('?') - if (searchIndex < 0) { - const hashIndex = href.indexOf('#') - if (hashIndex > -1) { - href = decodeURI(href.slice(0, hashIndex)) + href.slice(hashIndex) - } else href = decodeURI(href) - } else { - href = decodeURI(href.slice(0, searchIndex)) + href.slice(searchIndex) - } - return href }