-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base option is case sensitive #2154
Comments
Can confirm, is this a bug? |
it shouldn't matter in most cases as the base is something that comes from outside your application but it would be better for it to be case-insensitive by default, like the rest of the url |
I think I've found the issue. It appears to only affect router when in history mode. It's performing a case-sensitive comparison to remove the base path. Adding a couple toLowerCase() calls should fix it. If that's an acceptable solution I'm willing to put in a pull request and add some unit tests. vue-router/src/history/html5.js Lines 74 to 80 in 1c00c9f
|
Maybe even use a case-insensitive regex search instead. I'm not sure which is better performance wise. |
Just ran into this issue myself. In my case, I don't hit an error, because our app is hosted at /Locations on the server and a /Locations exists in the Router, but this is still really strange: domain.com/Locations => Home component ("/") Any other URL with the lowercase /locations will hit a 404. Any news on a fix being released for this? |
Any news on this? is there any workaround? |
@GHakopian @DinsmoreDesign Here's the snippet of code I had used for our workaround. Basically it just replaces the one vue-router function I referenced above. // Define router
const router = new VueRouter({
base: config.basePath,
routes,
mode: 'history'
})
// Route case-sensitivity hotfix
if (router.mode === 'history') {
router.history.getCurrentLocation = function() {
let path = window.location.pathname
let base = router.history.base
// Removes base from path (case-insensitive)
if (base && path.toLowerCase().indexOf(base.toLowerCase()) === 0) {
path = path.slice(base.length)
}
return (path || '/') + window.location.search + window.location.hash
}
} |
Ran into this issue today using v3.1.6, this has been on Long term roadmap for almost a year and is marked as a high priority. It is one line of code to make urls case-insensitive as the web standards allow. Can we get an update on when this will be fixed? I have used the fix proposed by PikminGuts92 and it works but this is still a hack and would prefer a permanent fix for a production application. |
Version
2.8.1
Reproduction link
https://github.com/dev-shane/vue-router-bug-demo
Steps to reproduce
My app is served under /app/, then I have config /src/router/index.js as follow
But I got this result
http://localhost:8080/app/home to /home
http://localhost:8080/app/Home to /home
http://localhost:8080/App/home to /error
http://localhost:8080/App/Home to /error
What is expected?
http://localhost:8080/app/home to /home
http://localhost:8080/app/Home to /home
http://localhost:8080/App/home to /home
http://localhost:8080/App/Home to /home
What is actually happening?
http://localhost:8080/app/home to /home
http://localhost:8080/app/Home to /home
http://localhost:8080/App/home to /error
http://localhost:8080/App/Home to /error
The text was updated successfully, but these errors were encountered: