Files
orca/src/shared/file-link-location.test.ts
Brennan Benson 0ed6db77cf fix(mobile): open agent-cited external chat files (#14166)
* fix(mobile): open agent-cited external chat files

* fix(mobile): keep cited external files read-only

* refactor(mobile): derive cited-file mode from provenance

* fix(mobile): accept sentence-final cited paths

* fix(mobile): preserve cited SSH grant scope

* refactor(file-links): share location suffix parsing
2026-08-13 01:12:19 -07:00

32 lines
947 B
TypeScript

import { describe, expect, it } from 'vitest'
import { parseFileLinkLocation } from './file-link-location'
describe('parseFileLinkLocation', () => {
it('parses agent-style line and column suffixes', () => {
expect(parseFileLinkLocation('src/main.ts:12:4')).toEqual({
pathText: 'src/main.ts',
line: 12,
column: 4
})
expect(parseFileLinkLocation('src/main.ts')).toEqual({
pathText: 'src/main.ts',
line: null,
column: null
})
})
it('preserves Windows drive colons', () => {
expect(parseFileLinkLocation(String.raw`C:\repo\src\main.ts:12`)).toEqual({
pathText: String.raw`C:\repo\src\main.ts`,
line: 12,
column: null
})
})
it('rejects empty paths and zero locations', () => {
expect(parseFileLinkLocation('')).toBeNull()
expect(parseFileLinkLocation('src/main.ts:0')).toBeNull()
expect(parseFileLinkLocation('src/main.ts:12:0')).toBeNull()
})
})