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. 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) {