Open wxwzl opened 3 years ago
3.4.9
https://vesaas.com/?a=1&b=2&a=2
input https://vesaas.com/?a=1&b=2&a=2 into webBroswer . then it becomes to https://vesaas.com/?a=1&a=2&b=2
do not trigger history.replaceState called
history.replaceState was called.
src/history/html5.js ensureURL (push?: boolean) { if (getLocation(this.base) !== this.current.fullPath) { const current = cleanPath(this.base this.current.fullPath) push ? pushState(current) : replaceState(current) } }
ensureURL (push?: boolean) { if (getLocation(this.base) !== this.current.fullPath) { const current = cleanPath(this.base this.current.fullPath) push ? pushState(current) : replaceState(current) } }
src/util/query.js `function parseQuery (query: string): Dictionary { const res = {}
query = query.trim().replace(/^(\?|#|&)/, '')
if (!query) { return res }
query.split('&').forEach(param => { const parts = param.replace(/\ /g, ' ').split('=') const key = decode(parts.shift()) const val = parts.length > 0 ? decode(parts.join('=')) : null
if (res[key] === undefined) { res[key] = val } else if (Array.isArray(res[key])) { res[key].push(val) } else { res[key] = [res[key], val] }
})
return res }`
Given the architecture on v3, it might be problematic to change the check to avoid calling replaceState. This was fixed on v4 and a contribution is welcome for vue router 3
replaceState
Version
3.4.9
Reproduction link
https://vesaas.com/?a=1&b=2&a=2
Steps to reproduce
input https://vesaas.com/?a=1&b=2&a=2 into webBroswer . then it becomes to https://vesaas.com/?a=1&a=2&b=2
What is expected?
do not trigger history.replaceState called
What is actually happening?
history.replaceState was called.
src/history/html5.js
ensureURL (push?: boolean) { if (getLocation(this.base) !== this.current.fullPath) { const current = cleanPath(this.base this.current.fullPath) push ? pushState(current) : replaceState(current) } }
src/util/query.js `function parseQuery (query: string): Dictionary {
const res = {}
query = query.trim().replace(/^(\?|#|&)/, '')
if (!query) { return res }
query.split('&').forEach(param => { const parts = param.replace(/\ /g, ' ').split('=') const key = decode(parts.shift()) const val = parts.length > 0 ? decode(parts.join('=')) : null
})
return res }`