Skip to content

Commit

Permalink
Merge pull request #1872 from hydephp/fix-realtime-compiler-subdirect…
Browse files Browse the repository at this point in the history
…ory-asset-serving

Fix realtime compiler not being able to serve media assets in subdirectories hydephp/develop@1d546ba
  • Loading branch information
github-actions authored and caendesilva committed Jul 22, 2024
1 parent 6feafcb commit 277b819
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Actions/AssetFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

namespace Hyde\RealtimeCompiler\Actions;

use Illuminate\Support\Str;

/**
* Locate a static file to proxy.
*/
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) {
Expand Down

0 comments on commit 277b819

Please sign in to comment.