vuejs / router

🚦 The official router for Vue.js
https://router.vuejs.org/
MIT License
3.88k stars 1.18k forks source link

Why does accessing base automatically add β€˜/’ after the route? #2219

Closed LeeSamFong closed 5 months ago

LeeSamFong commented 5 months ago

Reproduction

https://github.com/LeeSamFong/vue-router-demo

Steps to reproduce the bug

  1. Visit: http://localhost:5173/dist/aaa
  2. Observe that the browser address bar changes to: http://localhost:5173/dist/aaa/ There is an extra / at the end

    /dist/aaa -> /dist/aaa/

Expected behavior

When base is not the default value, / is not automatically added when accessing the home page.

Actual behavior

image image

When my base is not the default value, after accessing the root route /dist/aaa, / will be automatically added at the end, becoming ->/dist/aaa/

Additional information

No response

posva commented 5 months ago

It’s a convention, similar to example.com becoming example.com/.

LeeSamFong commented 5 months ago

But if I don't set the base, http://localhost:5173 will not be appended with /, and it will be automatically removed when '/' is included. Behaving inconsistently.


So is this a bug?

posva commented 5 months ago

it's not a bug, the browser hides the slash but if you check location, it's there