From d5582ffda5369bb3e639d18f6402c562bea7bd65 Mon Sep 17 00:00:00 2001 From: Keita Higuchi Date: Fri, 7 Feb 2025 11:06:01 +0900 Subject: [PATCH] fix: handle multibyte characters in scenario label correctly Fixed an issue where BackstopJS failed to process scenario labels containing multibyte characters (e.g., Japanese, Chinese). --- core/util/engineTools.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/util/engineTools.js b/core/util/engineTools.js index c07d7c10..5d6cea3d 100644 --- a/core/util/engineTools.js +++ b/core/util/engineTools.js @@ -51,7 +51,9 @@ function getSelectorName (selector) { } function makeSafe (str) { - return str.replace(/[ /]/g, '_'); + return str + .replace(/[^a-z0-9_-]/gi, (match) => encodeURIComponent(match)) + .replace(/[ /]/g, '_'); } function getFilename (fileNameTemplate, outputFileFormatSuffix, configId, scenarioIndex, scenarioLabelSafe, selectorIndex, selectorLabel, viewportIndex, viewportLabel) {