Skip to content

Commit 2961ba7

Browse files
github-actionscaendesilva
github-actions
authored andcommitted
Merge pull request #1872 from hydephp/fix-realtime-compiler-subdirectory-asset-serving
Fix realtime compiler not being able to serve media assets in subdirectories hydephp/develop@1d546ba
1 parent c6ad2a3 commit 2961ba7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Actions/AssetFileLocator.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,22 @@
44

55
namespace Hyde\RealtimeCompiler\Actions;
66

7+
use Illuminate\Support\Str;
8+
79
/**
810
* Locate a static file to proxy.
911
*/
1012
class AssetFileLocator
1113
{
1214
public static function find(string $path): ?string
1315
{
16+
$path = trim($path, '/');
17+
1418
$strategies = [
15-
BASE_PATH.'/_site'.$path,
16-
BASE_PATH.'/_media'.$path,
17-
BASE_PATH.'/_site'.basename($path),
18-
BASE_PATH.'/_media/'.basename($path),
19+
BASE_PATH.'/_site/'.$path,
20+
BASE_PATH.'/_media/'.$path,
21+
BASE_PATH.'/_site/'.Str::after($path, 'media/'),
22+
BASE_PATH.'/_media/'.Str::after($path, 'media/'),
1923
];
2024

2125
foreach ($strategies as $strategy) {

0 commit comments

Comments
 (0)