diff --git a/lib/inliner.php b/lib/inliner.php index a55c687..110bdcc 100644 --- a/lib/inliner.php +++ b/lib/inliner.php @@ -14,12 +14,12 @@ function inlineLocalStylesFromHref($inputString) { $cssContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $href); // Replace url() declarations in the CSS content with inline data - $cssContent = preg_replace_callback('/url\(["\']?(\/.*?)["\']?\)/i', function($urlMatch) { + $cssContent = preg_replace_callback('/url\(["\']?\/(.*?)(?:[?#].*?)?["\']?\)/i', function($urlMatch) { // Extract the URL value $url = $urlMatch[1]; // Get the content of the external file specified in the url() - $fileContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . $url); + $fileContent = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/' . $url); // Base64 encode the content for inline use $base64Content = base64_encode($fileContent);