mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 17:28:12 +08:00
Remove regex lookbehind in rasterization which is unsupported by Safari
This commit is contained in:
@@ -62,11 +62,12 @@ export function blobToBase64(blob: Blob): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function replaceBlobURLsWithBase64(svg: string): Promise<string> {
|
export async function replaceBlobURLsWithBase64(svg: string): Promise<string> {
|
||||||
const splitByBlobs = svg.split(/(?<=")(blob:.*?)(?=")/);
|
const splitByBlobs = svg.split(/("blob:.*?")/);
|
||||||
const onlyBlobs = splitByBlobs.filter((_, i) => i % 2 === 1);
|
const onlyBlobs = splitByBlobs.filter((_, i) => i % 2 === 1);
|
||||||
|
|
||||||
const onlyBlobsConverted = onlyBlobs.map(async (blobURL) => {
|
const onlyBlobsConverted = onlyBlobs.map(async (blobURL) => {
|
||||||
const data = await fetch(blobURL);
|
const urlWithoutQuotes = blobURL.slice(1, -1);
|
||||||
|
const data = await fetch(urlWithoutQuotes);
|
||||||
const dataBlob = await data.blob();
|
const dataBlob = await data.blob();
|
||||||
return blobToBase64(dataBlob);
|
return blobToBase64(dataBlob);
|
||||||
});
|
});
|
||||||
@@ -76,7 +77,7 @@ export async function replaceBlobURLsWithBase64(svg: string): Promise<string> {
|
|||||||
if (i % 2 === 0) return segment;
|
if (i % 2 === 0) return segment;
|
||||||
|
|
||||||
const blobsIndex = Math.floor(i / 2);
|
const blobsIndex = Math.floor(i / 2);
|
||||||
return base64Images[blobsIndex];
|
return `"${base64Images[blobsIndex]}"`;
|
||||||
});
|
});
|
||||||
return substituted.join("");
|
return substituted.join("");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user