From d81b473a810bab60008832a9b0c2a0b988962875 Mon Sep 17 00:00:00 2001 From: phinor <20402493+phinor@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:01:19 +0200 Subject: [PATCH] Fixes moveImportsToTop @charset directives would lose their semicolons after moveImportsToTop --- src/CSS.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CSS.php b/src/CSS.php index 4f56320..9922f39 100644 --- a/src/CSS.php +++ b/src/CSS.php @@ -90,14 +90,14 @@ public function setImportExtensions(array $extensions) */ protected function moveImportsToTop($content) { - if (preg_match_all('/(;?)(@import (?url\()?(?P["\']?).+?(?P=quotes)(?(url)\)));?/', $content, $matches)) { + if (preg_match_all('/;?(@import (?url\()?(?P["\']?).+?(?P=quotes)(?(url)\)));?/', $content, $matches)) { // remove from content foreach ($matches[0] as $import) { $content = str_replace($import, '', $content); } // add to top - $content = implode(';', $matches[2]) . ';' . trim($content, ';'); + $content = implode(';', $matches[1]) . ';' . trim($content, ';'); } return $content;