diff --git a/CHANGELOG.md b/CHANGELOG.md index 86d7058b1..6751a00ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Editor losing focus when project changes (#959) - Fix preview link (#912) - Web component code attribute (#963) +- Fix substring match on CSS images (#910) - Error message wrapping (#968) - Fix scrollbars not showing (#816) - Width of empty `p5` canvas (#969) diff --git a/src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx b/src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx index efa6de540..b29a30454 100644 --- a/src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx +++ b/src/components/Editor/Runners/HtmlRunner/HtmlRunner.jsx @@ -114,9 +114,11 @@ function HtmlRunner() { var updatedProjectFile = { ...projectFile }; if (projectFile.extension === "css") { projectImages.forEach((image) => { + const find = new RegExp(`['"]${image.filename}['"]`, "g"); // prevent substring matches + const replace = `"${image.url}"`; updatedProjectFile.content = updatedProjectFile.content.replaceAll( - image.filename, - image.url, + find, + replace, ); }); }