Skip to content

Commit 2bc7e30

Browse files
fix: toDataURL seeing data urls as paths
When given a data url `toDataURL` would try and read that as a file. This patch adds an additional check to see if something starts with `data:` which would indicate it is already a data URL.
1 parent 211f883 commit 2bc7e30

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/core/components/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ export const toDataURL = async function toDataURL(
8585
input: string,
8686
base: string = process.cwd()
8787
): Promise<string> {
88-
if (/^https?:\/\//iu.test(input)) {
89-
return urlToDataURL(input);
90-
}
88+
if (/^data:/iu.test(input)) return input;
89+
if (/^https?:\/\//iu.test(input)) return urlToDataURL(input);
9190

9291
let resolvedPath; // eslint-disable-line @typescript-eslint/init-declarations
9392
if (path.isAbsolute(input)) resolvedPath = input;

0 commit comments

Comments
 (0)