From d5d119a9dd58200e71ec108912ab41cc83deccf9 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 22 Jul 2024 10:29:05 +0200 Subject: [PATCH 1/2] Improve asset file locator to support serving subdirectory assets Fixes https://github.com/hydephp/realtime-compiler/issues/26 --- .../src/Actions/AssetFileLocator.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/realtime-compiler/src/Actions/AssetFileLocator.php b/packages/realtime-compiler/src/Actions/AssetFileLocator.php index 91b64d8dcca..d7ad8c57165 100644 --- a/packages/realtime-compiler/src/Actions/AssetFileLocator.php +++ b/packages/realtime-compiler/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) { From a5f142f970ad9fc68b5502ec35fe413c8e73ab3a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Mon, 22 Jul 2024 10:29:55 +0200 Subject: [PATCH 2/2] Update RELEASE_NOTES.md --- RELEASE_NOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 45d0c9b76f8..82376cb7b55 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -33,6 +33,7 @@ This serves two purposes: - Realtime Compiler: Updated the exception handler to match HTTP exception codes when sending error responses in https://github.com/hydephp/develop/pull/1853 - Realtime Compiler: Improved routing for nested index pages in https://github.com/hydephp/develop/pull/1852 - Realtime Compiler: Improved the dashboard https://github.com/hydephp/develop/pull/1866 fixing https://github.com/hydephp/realtime-compiler/issues/22 and https://github.com/hydephp/realtime-compiler/issues/29 +- Realtime Compiler: Fixed support for serving media assets in subdirectories https://github.com/hydephp/realtime-compiler/issues/26 in https://github.com/hydephp/develop/pull/1872 ### Security - in case of vulnerabilities.