-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
When using relative URLs, it creates errors.
The patch could be quite simple, something like that :
diff --git a/src/Middleware/AddHttp2ServerPush.php b/src/Middleware/AddHttp2ServerPush.php
index 253cf28..adb94d8 100644
--- a/src/Middleware/AddHttp2ServerPush.php
+++ b/src/Middleware/AddHttp2ServerPush.php
@@ -115,7 +115,9 @@ class AddHttp2ServerPush
$type = collect($linkTypeMap)->first(function ($type, $extension) use ($url) {
return str_contains(strtoupper($url), $extension);
});
-
+ if(!preg_match('%^https?://%i', $url)) {
+ $basePath = config('http2serverpush.base_path', '/');
+ $url = $basePath . ltrim($url, $basePath);
+ }
return is_null($type) ? null : "<{$url}>; rel=preload; as={$type}";
}
But it would require a config file...
In my case, base path is always '/'. But it could be any other path...
Metadata
Metadata
Assignees
Labels
No labels