Skip to content

Commit f236335

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 90fece2 commit f236335

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
@@ -2,18 +2,22 @@
22

33
namespace Hyde\RealtimeCompiler\Actions;
44

5+
use Illuminate\Support\Str;
6+
57
/**
68
* Locate a static file to proxy.
79
*/
810
class AssetFileLocator
911
{
1012
public static function find(string $path): ?string
1113
{
14+
$path = trim($path, '/');
15+
1216
$strategies = [
13-
BASE_PATH.'/_site'.$path,
14-
BASE_PATH.'/_media'.$path,
15-
BASE_PATH.'/_site'.basename($path),
16-
BASE_PATH.'/_media/'.basename($path),
17+
BASE_PATH.'/_site/'.$path,
18+
BASE_PATH.'/_media/'.$path,
19+
BASE_PATH.'/_site/'.Str::after($path, 'media/'),
20+
BASE_PATH.'/_media/'.Str::after($path, 'media/'),
1721
];
1822

1923
foreach ($strategies as $strategy) {

0 commit comments

Comments
 (0)