Skip to content

docs: document redirect pattern syntax, including regex parameters - #6563

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1786111850-document-redirect-pattern-syntax
Open

docs: document redirect pattern syntax, including regex parameters#6563
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1786111850-document-redirect-pattern-syntax

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

The redirects page only documented :slug and :slug*, but redirect matching passes the source straight to path-to-regexp 6.3.0, so regex-constrained parameters (:slug(.*), :version(\d+)) and unnamed groups have worked since fern-platform#1127 (Jul 2024) without ever being written down. Customers were left guessing whether mid-segment patterns were supported or incidental.

Adds a ## Pattern syntax section with the five usable forms, plus the two behaviors that aren't discoverable from the syntax itself:

  • The regex must be repeated in destination. source: "/plants-:slug(.*)" with destination: "/garden/:slug" fails to compile (a bare :slug can't hold a value containing /) and safeCompile falls back to emitting the destination verbatim — the user gets a redirect to the literal string /garden/:slug.
  • ? is unsupported. matchPath strips each source at the first ? to drop search params, so /old/:slug? is matched as /old/:slug and the optional modifier silently disappears.

Every claim was verified against the pinned path-to-regexp@6.3.0 by running the documented examples through getRedirectForPath:

✓ mid-segment regex param      /plants-:slug(.*)  → /garden-monstera/care   (/plants-:slug does not match)
✓ constrained param            /v:version(\d+)/…  → version = "2"
✓ unnamed group replays as :0  /plants/(\d+)      → /garden/42
✓ destination must repeat regex                   → /garden/:slug (literal)
✓ optional modifier stripped   /plants/:slug?     → no match for /plants

The zh translation is updated in the same shape.

Link to Devin session: https://app.devin.ai/sessions/ad30ef5780fe4114bad5fa79b1d195af

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot requested a review from devalog as a code owner August 7, 2026 14:11
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🌿 Preview your docs: https://fern-preview-devin-1786111850-document-redirect-pattern-syntax.docs.buildwithfern.com/learn

Here are the markdown pages you've updated:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant