Skip to content

Normalize Windows drive-letter localfile URLs before resolving file p…#1654

Open
Douglasymlai wants to merge 1 commit into
testfrom
fix/html-image-rendering
Open

Normalize Windows drive-letter localfile URLs before resolving file p…#1654
Douglasymlai wants to merge 1 commit into
testfrom
fix/html-image-rendering

Conversation

@Douglasymlai
Copy link
Copy Markdown
Contributor

Related Issue

Closes #TODO

Description

This PR fixes local HTML asset rendering issues in project content, especially when assets are loaded through localfile:// URLs on Windows.

It normalizes Windows drive-letter localfile paths in the Electron protocol handler, extracts local HTML asset rewriting into shared helpers, inlines both <img> elements and quoted local project image paths, and avoids incorrectly rewriting JavaScript template-literal placeholders such as ${...}. It also injects a local base href so relative asset references resolve more reliably.

Testing Evidence (REQUIRED)

  • Automated:

    • npx vitest run test/unit/electron/main/index.test.ts test/unit/lib/htmlLocalAssets.test.ts test/unit/lib/htmlSanitization.test.ts
    • Result: 3 test files passed, 98 tests passed
  • Manual:

    • Attach screenshot(s) or screen recording showing local HTML/image rendering works correctly
    • Include any human-verified reproduction/verification notes here
  • I have included human-verified testing evidence in this PR.

  • This PR includes frontend/UI changes, and I attached screenshot(s) or screen recording(s).

  • No frontend/UI changes in this PR.

Screenshot 2026-05-25 at 12 29 16

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Contribution Guidelines Acknowledgement

…aths and improve local HTML asset inlining for rendered project content.
@Douglasymlai Douglasymlai marked this pull request as ready for review May 25, 2026 11:51

/** Remove script blocks so img tag scans match real HTML, not JS template strings. */
export function stripScriptBlocks(html: string): string {
return html.replace(/<script[\s\S]*?<\/script>/gi, '');

/** Remove script blocks so img tag scans match real HTML, not JS template strings. */
export function stripScriptBlocks(html: string): string {
return html.replace(/<script[\s\S]*?<\/script>/gi, '');
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