From 2961ba7fd8d7c007ab9e6e65353f8c44c7768814 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 22 Jul 2024 08:33:19 +0000 Subject: [PATCH] Merge pull request #1872 from hydephp/fix-realtime-compiler-subdirectory-asset-serving Fix realtime compiler not being able to serve media assets in subdirectories https://github.com/hydephp/develop/commit/1d546ba2a212344a51083fba7418c86e5fed31ff --- src/Actions/AssetFileLocator.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Actions/AssetFileLocator.php b/src/Actions/AssetFileLocator.php index 91b64d8..d7ad8c5 100644 --- a/src/Actions/AssetFileLocator.php +++ b/src/Actions/AssetFileLocator.php @@ -4,6 +4,8 @@ namespace Hyde\RealtimeCompiler\Actions; +use Illuminate\Support\Str; + /** * Locate a static file to proxy. */ @@ -11,11 +13,13 @@ class AssetFileLocator { public static function find(string $path): ?string { + $path = trim($path, '/'); + $strategies = [ - BASE_PATH.'/_site'.$path, - BASE_PATH.'/_media'.$path, - BASE_PATH.'/_site'.basename($path), - BASE_PATH.'/_media/'.basename($path), + BASE_PATH.'/_site/'.$path, + BASE_PATH.'/_media/'.$path, + BASE_PATH.'/_site/'.Str::after($path, 'media/'), + BASE_PATH.'/_media/'.Str::after($path, 'media/'), ]; foreach ($strategies as $strategy) {