diff --git a/lib/inliner.php b/lib/inliner.php index d10154f..7342400 100644 --- a/lib/inliner.php +++ b/lib/inliner.php @@ -11,9 +11,16 @@ function inlineLocalStylesFromHref($inputString) { $cssContent = preg_replace_callback('/url\(["\']?(\/.*?|.*?)["\']?\)/i', function($urlMatch) use ($cssDir) { $url = $urlMatch[1]; - $absolutePath = $cssDir . '/' . $url; - $relativePath = ltrim(substr($absolutePath, strlen($_SERVER['DOCUMENT_ROOT'])), '/'); - return 'url("' . $relativePath . '")'; + + // Check if the URL starts with any protocol or // + if (!preg_match('/^([a-zA-Z]+:)?\/\//', $url)) { + $absolutePath = $cssDir . '/' . $url; + $relativePath = ltrim(substr($absolutePath, strlen($_SERVER['DOCUMENT_ROOT'])), '/'); + return 'url("' . $relativePath . '")'; + } else { + // If the URL starts with a protocol or //, leave it unchanged + return 'url("' . $url . '")'; + } }, $cssContent); // Minify the CSS content