Skip to content
Source
Sign inSign up
TanStack/router

Canonical links not respecting trailingSlash behaviour #6603

Openmarcellegane(GitHub profile, opens in a new tab) opened this issue 4 comments

Describe the bug

When trailingSlash: 'always' is set in createRouter, the canonical link href returned by a route's head() function and read through useRouterState via match.links does not have a trailing slash enforced.

The trailingSlash option correctly enforces trailing slashes on navigation URLs, but the href values in the links array on route matches are returned as-is without the trailing slash transformation applied.

Expected behavior

When trailingSlash: 'always' is configured, the router should ensure that href values in match.links also have a trailing slash appended.

How often does this bug happen?

Every time

Platform

  • @tanstack/react-router version 1.157.1
  1. @schiller-manuel I've investigated this and found that match.pathname is computed via interpolatePath() which is unaware of the trailingSlash option — would the preferred fix be to normalize match.pathname itself, or to add location to the head() context so users can access the already-normalized pathname there?

  2. first of all we need a reproducer for this issue

  3. schiller-manuel(GitHub profile, opens in a new tab) added labelsinformation needed

  4. can you please provide a reproducer?

  5. can you please provide a reproducer?

    Hi @schiller-manuel, here is a reproducer: https://stackblitz.com/edit/vitejs-vite-xhj5ijse?file=package.json

Sign in to join this conversation.