Description
Version
3.5.1
Reproduction link
https://jsfiddle.net/eyedean/4qcd9kgy/21/
Steps to reproduce
It's hard to reproduce in the jsfiddle and such. That's what I mentioned in the TODO
section of the link above.
Actual reproduction
- Let's say I have a Vue App with HTML5 History Router and RouterBase being
/a/
. - If I land on
www.mydomain.com/bpp/
, VueRouter properly shows the App's 404 (catch on/*/
in routes) page. - However if I land on
www.mydomain.com/app
, then Vue Router redirects it towww.mydomain.com/a/pp
which is not expected. (Assume/a/pp
is an existing page, and not the intended target of/app
)
What is expected?
show 404 on /app
, just like /bpp
.
What is actually happening?
redirects it to /a/pp
, which can be a different existing page.
I tried to debug this on my own. Here is what I found.
When I set VueRouterBase to /a/
(with trailing slash, as advised in the documentation), router.options.base
is properly /a/
, but the history.base
is going through normalizeBase
and becomes /a
. That's why /app
gets sliced (via
vue-router/src/history/html5.js
Lines 90 to 92 in 677f3c1
path: "/pp"
.
I also tried getting around this by setting routerbase to /a//
(double trailing slash). It stopped the /app
=> /a/pp
redirect, successfully, but then all my links were ugly! (e.g. <router-link to="/login">
would produce www.mydomain.com/a//login
with double slash in between.)