Skip to content

Problem with escaping backslashes in custom regex in params #2637

@jottemm

Description

@jottemm

Version

5.0.3

Reproduction link

paths.esm.dev/

Steps to reproduce

  1. Update your version of vue-router to 5.0.3.

  2. Use a custom regex to define i.e. an id in a route as a digit
    Try example in version 5.0.3:

definePage({
  path: "/pathxyz/:id(\\d+)",
});

(In version 5.0.2 this still works.)

  1. If you have a catch all page, you'll end up there.

If you use the following instead in version 5.0.3, it will work:

definePage({
  path: "/pathxyz/:id([0-9]+)",
});

But I think, that this is at least just a workaround. Or you stay at version 5.0.2 ...

What is expected?

Custom regex is working. You get the desired route and page.

What is actually happening?

Custom regex seems to fail because you fall into the catch all page. I think, the backslashes get lost.


I refer to this point in the Vue Router docs: https://router.vuejs.org/guide/essentials/route-matching-syntax.html#Custom-regex-in-params

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions