Fix Windows file:// URL path handling in image processing #212
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using
html2pptxon Windows with relative image paths in HTML files (e.g.,<img src="assets/icon.png">), the image loading fails with a "file not found" error.Root Cause:
When Playwright renders HTML, relative image paths are automatically converted to absolute
file://URLs. For example:assets/icon.pngfile:///D:/project/slides/assets/icon.pngThe existing code strips the
file://prefix:However, this leaves a path like
/D:/project/slides/assets/icon.png(note the leading slash). When PptxGenJS processes this path, it interprets it as a relative path and prepends the current working directory, resulting in a malformed path:Solution
Added a check to detect and fix Windows-style paths that start with
/[drive-letter]:/:This removes the leading slash, producing a valid Windows absolute path like
D:/project/slides/assets/icon.png.Testing
/[A-Z]:/pattern)