claudetech / node-static-i18n

HTML static pages i18n tool
https://www.npmjs.com/package/static-i18n
MIT License
102 stars 21 forks source link

Treat URLs like data:image/svg+xml as absolute to support inlining images in html #54

Closed miksto closed 8 months ago

miksto commented 11 months ago

Currently a URL like data:image/svg+xml;base64,foo is considered a relative URL, which means that an image tag like this:

<img src="data:image/svg+xml;base64,foo" />

gets re-written to

<img src="../data:image/svg+xml;base64,foo" />

which of course is not supported by the browser.

This PR fixes this issue by adjusting the absolutePathRegex to consider URLs that start with the format data:image/<image-format>; as absolute as well.

This solution could potentially be expanded to be more general and treat anything that starts with data: as an absolute url. I am unsure about the use cases though, and opted for a less generic solution.

danhper commented 8 months ago

Thanks, and sorry for the delay!