TanStack / TanStack/router

Canonical links not respecting trailingSlash behaviour

Open
#6,603 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

information needed
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the createRouter trailingSlash handling and trace how a route's head() output becomes match.links, including the useRouterState entry point. Verify the behavior with trailingSlash: 'always' and ensure canonical href values receive the same trailing-slash treatment as navigation URLs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.