From 4190bf79339330601b4d6d426c45cfc6e431ef61 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 26 Oct 2023 14:13:04 +0200 Subject: [PATCH] Fix: handle NBSP in svg --- scripts/generateIncludedImages.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/generateIncludedImages.ts b/scripts/generateIncludedImages.ts index 083440c1ed..94c5638502 100644 --- a/scripts/generateIncludedImages.ts +++ b/scripts/generateIncludedImages.ts @@ -26,10 +26,14 @@ function genImages(dryrun = false) { .replace(/\r/g, "") .replace(/\\/g, "\\") .replace(/"/g, '\\"') + .replaceAll(" ", " ") - let hasNonAsciiChars = Array.from(svg).some((char) => char.charCodeAt(0) > 127) - if (hasNonAsciiChars) { - throw "The svg '" + path + "' has non-ascii characters" + let hasNonAsciiChars = Array.from(svg) + .filter((char) => char.charCodeAt(0) > 127) + .map((char) => char.charCodeAt(0)) + .join(", ") + if (hasNonAsciiChars.length > 0) { + throw "The svg '" + path + "' has non-ascii characters: " + hasNonAsciiChars } const name = path.substring(0, path.length - 4).replace(/[ -]/g, "_")