TanStack
OSS
router
Sign in / Sign up
Open main menu
router
Overview
Runs
Analytics
Loading workspace stats
Loading workspace insights...
Statistics interval
7 days
30 days
Latest CI Pipeline Executions
Status
Fix filter
Filter
Fuzzy
Filter range
Sort by
Sort by
Start time
Sort ascending
Sort descending
Succeeded
6156
f1256b31 ci: apply automated fixes
18 days ago
by autofix-ci...
a
Succeeded
6156
20cb3f0f add e2e test
18 days ago
by schiller-m...
s
Canceled
6156
3faae7e6 ci: apply automated fixes
18 days ago
by autofix-ci...
a
Canceled
6156
29391b73 add utils unit tests
18 days ago
by schiller-m...
s
Canceled
6156
6c9eb8ea fix test
18 days ago
by schiller-m...
s
Failed
6156
0612d581 simplify
18 days ago
by schiller-m...
s
Failed
6156
ea9a657b 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
18 days ago
by schiller-m...
s
Previous page
Previous
Next
Next page