Skip to content

Commit

Permalink
fix for vendor files
Browse files Browse the repository at this point in the history
  • Loading branch information
pxpm committed Dec 26, 2024
1 parent 8785565 commit 306d622
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/AssetPathManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public function getBasePath(): string
public function getPathOnDisk(string $asset): string
{
return Str::of($this->basePath)
->append($this->getCleanPath($asset));
->append($this->getCleanPath($asset))
->replace(['//'], '/');
}

public function getCleanPath(string $asset): string
{
return Str::of($asset)
->replace([base_path().'/', base_path(), 'http://', 'https://', '://', '<', '>', ':', '"', '|', "\0", '*', '`', ';', "'", '+'], '')
->replace([base_path().'/', base_path(), base_path().'\\', 'http://', 'https://', '://', '<', '>', ':', '"', '|', "\0", '*', '`', ';', "'", '+'], '')
->before('?')
->replace(['/\\', '\\'], '/');
}
Expand Down
11 changes: 7 additions & 4 deletions src/Helpers/CacheEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public function assetPath(string $assetPath): self
{
$this->assetPath = $assetPath;

if (! str_starts_with(base_path(), $assetPath) && ! Str::isUrl($assetPath)) {
// if asset path is not a full path, we assume it's a relative path to the public folder
$this->assetPath = public_path($assetPath);
$this->assetDiskPath = $this->assetPathsManager->getCleanPath($this->assetPath);
if (! str_starts_with($assetPath, base_path()) && ! Str::isUrl($assetPath)) {
if (File::exists(public_path($assetPath))) {
$this->assetPath = public_path($assetPath);
$this->assetDiskPath = $this->assetPathsManager->getCleanPath($this->assetPath);
} else {
$this->assetPath = base_path($assetPath);
}
}

if (! isset($this->assetDiskPath)) {
Expand Down

0 comments on commit 306d622

Please sign in to comment.