* fix(history): preserve unload blockers during back and forward navigation
* fix(history): respect ignoreBlocker in go navigation
* fix(history): reverse blocked traversal by its delta
* fix(router-core): preserve percent-encoded URL-unsafe chars in decodeSegment
Replace sanitizePathSegment (which stripped control characters) with a
re-encode step that keeps WHATWG path percent-encode set characters and
control characters in their encoded form after decodeURI.
This preserves the existing decodeURI-based approach which correctly
handles multi-byte UTF-8 sequences, while fixing the mismatch between
the original request URL and the router's internal representation that
caused infinite 307 redirect loops on paths containing these characters.
Fixes#7587.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* ci: apply automated fixes
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Flo <me@florianpellet.com>
* fix(start-plugin-core): support rsbuild preview SSR
* fix(start-plugin-core): always install rsbuild SSR middleware in preview
Preview is the only SSR handler in `rsbuild preview`, so gate the opt-out
to dev only and keep the option named `installDevServerMiddleware`.
* fix: shared virtual module for code-split routes
When a route file has module-level bindings (variables, functions, classes) referenced by **both** split and non-split route properties, the bindings are duplicated — initialized independently in the reference file and in each virtual split file. This breaks singletons, causes double side effects, and wastes bundle size.
```tsx
const collection = { name: 'todos', preload: async () => {} }
export const Route = createFileRoute('/todos')({
loader: async () => {
await collection.preload()
}, // stays in reference
component: () => <div>{collection.name}</div>, // split to virtual
})
```
In this example, `collection` is initialized in **both** the reference file (because `loader` references it) and the `?tsr-split=component` virtual file (because the component references it). Two separate instances exist at runtime.
To solve this issue, this PR introduces a third virtual module `route.tsx?tsr-shared=1` that contains shared bindings. Both the reference and virtual files import from it.
When `sharedBindings` is empty (the common case — component-only helpers, loader-only code), no shared module exists and the system works exactly as today.
The reference transform runs first and will emit a static import of `?tsr-shared=1` **only when needed**. Since split chunks are only discovered via the reference file's emitted `import('...?tsr-split=...')`, the bundler will always process/evaluate the reference module first. Result: the shared module is evaluated once and then reused by any later-loaded split chunk.
* fix: optimize match retrieval by using a Map for previous matches
* feat: add strict false parameter handling and related routes
* replace params only when routeParams is fully parsed
---------
Co-authored-by: Nico Lynzaad <nlynzaad@zylangroup.com>
Co-authored-by: Nico Lynzaad <44094871+nlynzaad@users.noreply.github.com>
* feat(router-generator): allow escaping any special string in file-based routing
This change extends the router-generator's escaping mechanism to allow ANY
special string to be escaped using square bracket syntax, not just dots.
## Problem
Previously, the router-generator only supported escaping dots using [.]
syntax (e.g., script[.]js.tsx -> /script.js). However, special strings
like 'index', 'route', 'lazy', and underscores ('_') could not be escaped,
making it impossible to create routes with literal paths like /index,
/route, /lazy, or paths containing literal underscores.
## Solution
Extended the escaping mechanism to support:
1. **Escaped special suffixes**: [index], [route], [lazy], [component], etc.
- [index].tsx -> /index (literal path, NOT treated as index route)
- [route].tsx -> /route (literal path, NOT treated as layout config)
- [lazy].tsx -> /lazy (literal path, NOT treated as lazy-loaded route)
2. **Escaped underscores in any position**:
- Leading: [_]layout.tsx -> /_layout (literal, NOT pathless layout)
- Trailing: blog[_].tsx -> /blog_ (literal, NOT escaping parent layout)
- Middle: foo[_]bar.tsx -> /foo_bar (literal underscore preserved)
- Multiple: api[_]v2[_]users.tsx -> /api_v2_users
- Fully escaped: [_prefix_middle_suffix].tsx -> /_prefix_middle_suffix
3. **Custom token escaping**: Works with custom indexToken and routeToken
- [_1nd3x].tsx with indexToken='_1nd3x' -> /_1nd3x (literal path)
- posts.[_r0ut3_].tsx with routeToken='_r0ut3_' -> /posts/_r0ut3_
## Implementation Details
### src/utils.ts
- Removed '_' from DISALLOWED_ESCAPE_CHARS to allow underscore escaping
- Added isSegmentEscaped() to check if a segment was bracket-escaped
- Added hasEscapedLeadingUnderscore() to detect [_] prefix or [_...] patterns
- Added hasEscapedTrailingUnderscore() to detect [_] suffix or [..._] patterns
- Added removeUnderscoresWithEscape() to preserve escaped underscores
- Added removeLayoutSegmentsWithEscape() to preserve escaped layout segments
- Added isSegmentPathless() to check for non-escaped leading underscores
- Updated inferFullPath() to use escape-aware functions
### src/filesystem/physical/getRouteNodes.ts
- Added escape checking for special suffixes (route, lazy, component, etc.)
- Updated isValidPathlessLayoutRoute() to check for escaped underscores
- Updated getRouteMeta() to accept originalRoutePath and check escaping
### src/generator.ts
- Updated handleNode() to use escape-aware path processing functions
- Compute trimmedOriginalPath alongside trimmedPath for escape detection
## Tests Added
- escaped-special-strings: Tests escaping of index, route, lazy, and
underscores in various positions (leading, trailing, middle, multiple)
- escaped-custom-tokens: Tests escaping with custom indexToken and
routeToken configurations
* simplify
* fix test
* add utils unit tests
* add e2e test
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>