Skip to content

fix: cut bare URLs at non-URL characters and mask markdown links - #184

Merged
rogerdigital merged 1 commit into
mainfrom
fix/external-url-unicode-boundary
Sep 18, 2026
Merged

rogerdigital merged 1 commit into
mainfrom
fix/external-url-unicode-boundary

Conversation

@rogerdigital

Copy link
Copy Markdown
Owner

Problem

Follow-up to #172: the ASCII trailing-trim from #175 does not cover Unicode punctuation (curly quotes/apostrophes, CJK brackets), and cannot handle punctuation followed by more prose characters — *[t](url)*’s was checked as …a)*’s and a bare https://x.com/a’s kept the apostrophe and suffix, because trailing-trim stops at the first non-trimmable character (s) (issue comment).

Change

Two principled layers replace character-set whack-a-mole in extractBareUrls:

  • Markdown link masking — [text](dest) syntax is blanked before bare extraction (like code spans). URLs in link syntax are collected from link metadata, so anything glued to the syntax (emphasis, curly quotes, possessives, CJK brackets) never reaches the extractor at all.
  • RFC 3986 character cut — a captured bare URL is cut at the first character that cannot appear in a URL (ASCII URL grammar plus unicode letters/numbers/combining marks). Unencoded non-ASCII punctuation is never valid URL syntax — conforming URLs percent-encode it — so ’, ”, 」, 。 cut there, while IDN paths like …/wiki/日本語 survive intact.

The ASCII trailing trim (sentence punctuation, emphasis markers, balanced-paren guard) is retained for trailing grammar-valid junk like ).,;*_~. Nested-bracket link labels fall through to bare extraction cleanly and dedupe against the metadata link.

Validation

  • TDD: 10 new boundary cases observed failing first (including the reporter's curly-quote and possessive shapes), then passing; the 44-test external-links suite is green with existing parenthesis/emphasis/balance cases unchanged.
  • Full gate: npm run lint && npm run lint:obsidian-warnings && npm run build && npm test — 976 tests pass.

Follow-up to #172

@rogerdigital
rogerdigital merged commit c47f10b into main Sep 18, 2026
3 checks passed
@rogerdigital
rogerdigital deleted the fix/external-url-unicode-boundary branch September 18, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant