From 2f4c0b4d43e3c12ca4eebe58104935472b51f8bd Mon Sep 17 00:00:00 2001 From: Avad3 <65318266+Avad3@users.noreply.github.com> Date: Wed, 26 Jun 2024 01:02:05 -0400 Subject: [PATCH] Update css.ts --- src/bundle/rewriters/css.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundle/rewriters/css.ts b/src/bundle/rewriters/css.ts index 84b3839..8868b31 100644 --- a/src/bundle/rewriters/css.ts +++ b/src/bundle/rewriters/css.ts @@ -1,9 +1,9 @@ import { encodeUrl } from "./url"; export function rewriteCss(css: string, origin?: URL) { - css = css.replace(/(?<=url\("?'?)[^"'][\S]*[^"'](?="?'?\);?)/g, (match) => encodeUrl(match, origin)); + css = css.replace(/(?<=url\("?'?)[^"'][\S]*[^"'](?="?'?\);?)/gm, (match) => encodeUrl(match, origin)); //painful regex simulator - css = css.replace(/@import\s+(['"])?([^'"\);]+)\1?\s*(?:;|$)/g, (match, quote, url) => { + css = css.replace(/@import\s+(['"])?([^'"\);]+)\1?\s*(?:;|$)/gm, (match, quote, url) => { return `@import ${quote || ""}${encodeUrl(url.trim(), origin)}${quote || ""};`; }); return css;