mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-29 16:50:12 +02:00
Removed use of mix-manifest
This commit is contained in:
@@ -15,7 +15,7 @@ class FinderProvider
|
||||
{
|
||||
/** @const Application paths to be hidden */
|
||||
protected const APP_FILES = [
|
||||
'app', 'node_modules', 'vendor', 'mix-manifest.json', 'index.php'
|
||||
'app', 'node_modules', 'vendor', 'index.php'
|
||||
];
|
||||
|
||||
/** @const Array of sort options mapped to their respective methods */
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\ViewFunctions;
|
||||
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
class Asset extends ViewFunction
|
||||
{
|
||||
/** @const Constant description */
|
||||
@@ -21,30 +19,8 @@ class Asset extends ViewFunction
|
||||
*/
|
||||
public function __invoke(string $path): string
|
||||
{
|
||||
$assetPath = self::ASSET_PATH . $path;
|
||||
$assetPath = dirname($_SERVER['SCRIPT_NAME']) . self::ASSET_PATH . ltrim($path, '/');
|
||||
|
||||
if ($this->mixManifest()->has($assetPath)) {
|
||||
return $this->mixManifest()->get($assetPath);
|
||||
}
|
||||
|
||||
return $assetPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mix manifest collection.
|
||||
*
|
||||
* @return \Tightenco\Collect\Support\Collection
|
||||
*/
|
||||
protected function mixManifest(): Collection
|
||||
{
|
||||
$mixManifest = $this->container->get('base_path') . '/mix-manifest.json';
|
||||
|
||||
if (! is_file($mixManifest)) {
|
||||
return new Collection();
|
||||
}
|
||||
|
||||
return Collection::make(
|
||||
json_decode(file_get_contents($mixManifest), true) ?? []
|
||||
);
|
||||
return '/' . ltrim($assetPath, '/');
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,5 @@ vendor
|
||||
.env.example
|
||||
directory-lister.svg
|
||||
LICENSE
|
||||
mix-manifest.json
|
||||
README.md
|
||||
index.php
|
||||
|
@@ -5,6 +5,5 @@ vendor
|
||||
.htaccess
|
||||
directory-lister.svg
|
||||
LICENSE
|
||||
mix-manifest.json
|
||||
README.md
|
||||
index.php
|
||||
|
@@ -24,6 +24,8 @@ class TestCase extends PHPUnitTestCase
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$_SERVER['SCRIPT_NAME'] = '/index.php';
|
||||
|
||||
$this->config = new Config([
|
||||
'app' => [
|
||||
'sort_order' => 'type',
|
||||
|
@@ -11,19 +11,7 @@ class AssetTest extends TestCase
|
||||
{
|
||||
$asset = new Asset($this->container, $this->config);
|
||||
|
||||
$this->assertEquals('/app/dist/test.css', $asset('test.css'));
|
||||
$this->assertEquals(
|
||||
'/app/dist/app.css?id=417c7a9bc03852aafb27',
|
||||
$asset('app.css')
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_can_return_an_asset_path_without_a_mix_manifest(): void
|
||||
{
|
||||
$this->container->set('base_path', $this->filePath('subdir'));
|
||||
$asset = new Asset($this->container, $this->config);
|
||||
|
||||
$this->assertEquals('/app/dist/test.css', $asset('test.css'));
|
||||
$this->assertEquals('/app/dist/app.css', $asset('app.css'));
|
||||
$this->assertEquals('/app/dist/css/app.css', $asset('css/app.css'));
|
||||
$this->assertEquals('/app/dist/js/app.js', $asset('js/app.js'));
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"/app/dist/app.js": "/app/dist/app.js?id=6753a7269276c7b52692",
|
||||
"/app/dist/app.css": "/app/dist/app.css?id=417c7a9bc03852aafb27"
|
||||
}
|
Reference in New Issue
Block a user