fix: keep framework route terminal links whole (#4036)

This commit is contained in:
Neil
2026-05-31 02:05:13 -07:00
committed by GitHub
parent 3aa4b36efe
commit f0125d2dbf
2 changed files with 16 additions and 1 deletions
@@ -119,6 +119,19 @@ describe('terminal path helpers', () => {
})
})
it('detects framework route paths with bracket and paren segments', () => {
const links = extractTerminalFileLinks(
'Error in app/(shop)/products/[productId]/page.tsx:42:7'
)
expect(links).toHaveLength(1)
expect(links[0]).toMatchObject({
pathText: 'app/(shop)/products/[productId]/page.tsx',
line: 42,
column: 7,
displayText: 'app/(shop)/products/[productId]/page.tsx:42:7'
})
})
it('handles large spaced path lists without quadratic overlap scans', () => {
const line = Array.from({ length: 20_000 }, () => '/tmp/Foo Bar/file').join(', ')
+3 -1
View File
@@ -25,8 +25,10 @@ export type ResolvedTerminalFileLink = Pick<ParsedTerminalFileLink, 'line' | 'co
// Matches a path with at least one `/` separator, optionally followed by
// `:line` and `:col` suffixes (e.g. `src/foo.ts:12:3`, `./bin`, `/abs/path`).
// Why: framework route files commonly use punctuation segments like
// `app/(shop)/products/[id]/page.tsx`; keep those links whole.
const LOCAL_PATH_REGEX =
/(?:~[\\/]|[\\/]|\.{1,2}[\\/]|[A-Za-z]:[\\/]|[A-Za-z0-9._-]+[\\/])[A-Za-z0-9._~\-/%+@\\]*(?::\d+)?(?::\d+)?/g
/(?:~[\\/]|[\\/]|\.{1,2}[\\/]|[A-Za-z]:[\\/]|[A-Za-z0-9._-]+[\\/])[A-Za-z0-9._~\-/%+@\\()[\]]*(?::\d+)?(?::\d+)?/g
// Matches separator paths whose file or folder names include spaces. This runs
// before LOCAL_PATH_REGEX so `/Users/A/Foo Bar/file.ts` is claimed as one link