Skip to content

Commit

Permalink
fix(h5): check location.pathname out of router.base
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Nov 16, 2022
1 parent 57812d5 commit 928cb18
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/service/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ function getHash () {

function getLocation (base = '/') {
let path = decodeURI(window.location.pathname)
const search = window.location.search
const hash = window.location.hash
// 检查和纠正 path
if (base[base.length - 1] === '/' && path === base.substring(0, base.length - 1)) {
path = base
window.history.replaceState({}, '', base + search + hash)
}
if (base && path.indexOf(base) === 0) {
path = path.slice(base.length)
}
return (path || '/') + window.location.search + window.location.hash
return (path || '/') + search + hash
}

/**
Expand Down Expand Up @@ -207,4 +214,4 @@ export default {
Vue.use(VueRouter)
}

}
}

0 comments on commit 928cb18

Please sign in to comment.