Skip to content

[Bug]: matchPath returns null on path validation regex #10720

@hasahmad

Description

@hasahmad

What version of React Router are you using?

6.3.0

Steps to Reproduce

import { matchPath } from "react-router-dom";

matchPath(
  { path: '/project/:type(type1|type2|type3|type4)/task/:taskId'},
  '/project/type3/task/123'
); // returns null

Expected Behavior

should returned matched path value instead of null

{
  params: {type: 'type3', taskId: '123'},
  pathname:  '/project/type3/task/123',
  pathnameBase: '/project/type3/task/123',
  pattern: { path: '/project/:type/task/:taskId', }
}

Actual Behavior

This returns null insted of matched url.
This worked on v5, but not in v6 anymore. Is this intentional in v6?

matchPath(
  { path: '/project/:type(type1|type2|type3|type4)/task/:taskId'},
  '/project/type3/task/123'
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions