Skip to content

fix: decode URI-encoded local link paths - #29

Merged
Neilooo merged 1 commit into
Neilooo:mainfrom
andyhrc:fix/unicode-local-links
Sep 8, 2026
Merged

fix: decode URI-encoded local link paths#29
Neilooo merged 1 commit into
Neilooo:mainfrom
andyhrc:fix/unicode-local-links

Conversation

@andyhrc

@andyhrc andyhrc commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Decode URI-encoded local paths before resolving them against the current Markdown file
  • Apply the same path handling to internal document links and local images
  • Preserve malformed URI escapes from raw HTML instead of aborting link rewriting

Problem

MarkdownIt percent-encodes non-ASCII link destinations. For example, ./目录/中文文件.md#中文标题 is rendered with %E7... path segments. The existing code joined those encoded segments directly into the filesystem path, so readTextFile looked for a literal percent-encoded filename and navigation failed.

The fragment is split before decoding, so encoded heading IDs keep their existing behavior.

Validation

  • pnpm lint
  • pnpm build
  • Manually verified encoded Chinese directories and filenames resolve to their Unicode filesystem paths
  • Manually verified escaped spaces/filename characters and malformed % sequences

Decode MarkdownIt's URI escaping before resolving local links and images, while preserving malformed raw HTML URLs.
@Neilooo
Neilooo merged commit ebfbc02 into Neilooo:main Sep 8, 2026
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.

2 participants