Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Trailing slashes in router path are not present in useMatches parent results #11239

Open
davidjayb opened this issue Jan 31, 2024 · 0 comments
Labels

Comments

@davidjayb
Copy link

What version of React Router are you using?

6.11.0

Steps to Reproduce

Create a router with parent and child routes. Each route has a trailing slash in the path.

The example below removes some required fields for brevity.

Router.jsx

createBrowserRouter([
  {
    path: 'parent/',
    children: [
      {
        path: 'child/'
      }
    ]
  }
]);

Breadcrumbs.jsx

export default function Breadcrumbs() {
    const matches = useMatches();
    matches.forEach(match => console.log(match.pathname))
}

Expected Behavior

The output in the console should include a trailing slash for each match pathname. This is useful for consistency in resolving URLs, especially in conjunction with the NavLink.end property: https://reactrouter.com/en/main/components/nav-link#end

Actual Behavior

The following will be printed in the console:

/parent
/parent/child/
@davidjayb davidjayb added the bug label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant