mirror of
https://github.com/stablyai/orca.git
synced 2026-10-06 00:02:43 +00:00
* 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
20 lines
580 B
TypeScript
20 lines
580 B
TypeScript
export type ParsedFileLinkLocation = {
|
|
pathText: string
|
|
line: number | null
|
|
column: number | null
|
|
}
|
|
|
|
export function parseFileLinkLocation(value: string): ParsedFileLinkLocation | null {
|
|
const match = /^(.*?)(?::(\d+))?(?::(\d+))?$/.exec(value)
|
|
const pathText = match?.[1]
|
|
if (!pathText) {
|
|
return null
|
|
}
|
|
const line = match[2] ? Number.parseInt(match[2], 10) : null
|
|
const column = match[3] ? Number.parseInt(match[3], 10) : null
|
|
if ((line !== null && line < 1) || (column !== null && column < 1)) {
|
|
return null
|
|
}
|
|
return { pathText, line, column }
|
|
}
|