From fe21bc9232ef0db0cb143490353ffe7bf2257e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Tue, 3 May 2022 14:34:29 -0700 Subject: [PATCH 1/2] remove unused variable --- src/RewriteAssetUrls.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RewriteAssetUrls.php b/src/RewriteAssetUrls.php index 8a4bf9c4..7bd71ebc 100644 --- a/src/RewriteAssetUrls.php +++ b/src/RewriteAssetUrls.php @@ -16,7 +16,7 @@ class RewriteAssetUrls public static function inCssString($css, $baseUrl) { return preg_replace_callback('/url\([\'"]?(?[^)]+?)[\'"]?\)/', function ($matches) use ($baseUrl) { - return Str::startsWith($url = $matches[1], ['/']) + return Str::startsWith($matches[1], ['/']) ? Str::replaceFirst('/', $baseUrl.'/', $matches[0]) : $matches[0]; }, $css); From 067f44aee9347dc01b51d530746e382150ae88c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kr=C3=BCss?= Date: Tue, 3 May 2022 14:41:12 -0700 Subject: [PATCH 2/2] cleanup --- src/RewriteAssetUrls.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RewriteAssetUrls.php b/src/RewriteAssetUrls.php index 7bd71ebc..bcba8ecd 100644 --- a/src/RewriteAssetUrls.php +++ b/src/RewriteAssetUrls.php @@ -16,8 +16,8 @@ class RewriteAssetUrls public static function inCssString($css, $baseUrl) { return preg_replace_callback('/url\([\'"]?(?[^)]+?)[\'"]?\)/', function ($matches) use ($baseUrl) { - return Str::startsWith($matches[1], ['/']) - ? Str::replaceFirst('/', $baseUrl.'/', $matches[0]) + return Str::startsWith($matches[1], '/') + ? Str::replaceFirst('/', "{$baseUrl}/", $matches[0]) : $matches[0]; }, $css); }