4c - the label trim, the segment tail, the break run and the guard's spread stop re-walking

This commit is contained in:
2026-09-18 18:04:44 +02:00
parent 9d780aa910
commit 4ad8a9228c
6 changed files with 60 additions and 15 deletions
+4 -4
View File
@@ -17,10 +17,10 @@ export function readLabel(text: string, offset: number): LinkPart | undefined {
}
export function normalizeLabel(raw: string): string {
return raw
.replace(/^[ \t\n]+|[ \t\n]+$/g, '')
.replace(/[ \t\n]+/g, ' ')
.toLowerCase()
const collapsed = raw.replace(/[ \t\n]+/g, ' ')
const start = collapsed.startsWith(' ') ? 1 : 0
const end = collapsed.endsWith(' ') ? collapsed.length - 1 : collapsed.length
return collapsed.slice(start, end).toLowerCase()
}
export function readDestination(text: string, offset: number): LinkPart | undefined {