Skip to content

Linking to fragments causes HTML5 history based router to trigger a redirect to base URL #990

@rolftimmermans

Description

@rolftimmermans

I have this router:

const router = new VueRouter({
  mode: "history",
  base: "/foo",
  routes: [
    { path: "/invoices", component: Invoicing },
  ],
})

On one page, there is this link:

<a href="#order">order product</a>

When the link is clicked, it causes a redirect to /foo! That's not expected given that I use HTML5 history mode.

I can see it is caused by this line: https://github.com/vuejs/vue-router/blob/dev/src/history/html5.js#L26

A hash change causes a HTML popstate event, which causes the router to redirect. I don't want that, I actually never want the router to do anything when the hash of the URL changes. To me this seems like a bug. Am I missing something?

(Note; I can understand this behaviour for hash mode, but I am using history mode)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions