Skip to content

Commit 441bbb7

Browse files
author
Gaige Lama
authored
Merge pull request #15 from ExoUNX/dev
Added check on how to handle filename
2 parents 11fbb42 + 6e72493 commit 441bbb7

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/ManifestBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ private function loopManifest(array $mixManifest, array &$vasriManifest = []): v
104104
if ($this->isMixManifestAltEnabled) {
105105

106106
foreach ($mixManifest as $key => $val) {
107-
$vasriManifest[] = $val;
107+
$vasriManifest[] = [
108+
$key => [
109+
'alt' => $val
110+
]
111+
];
108112
}
109113

110114
} else {

src/Vasri.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,22 @@ class Vasri
4444
*/
4545
private $vasriConfig;
4646

47+
/**
48+
* @var
49+
*/
50+
private $isMixManifestAltEnabled;
51+
4752
/**
4853
* Vasri constructor.
4954
*/
5055
public function __construct()
5156
{
52-
$this->builder = new Builder();
53-
$this->manifestReader = new ManifestReader();
54-
$this->vasriConfig = config('vasri');
55-
$this->vasriManifest = $this->manifestReader->getManifest(base_path('vasri-manifest.json'));
56-
$this->appEnvironment = env('APP_ENV', 'production');
57+
$this->builder = new Builder();
58+
$this->manifestReader = new ManifestReader();
59+
$this->vasriConfig = config('vasri');
60+
$this->isMixManifestAltEnabled = $this->vasriConfig['mix-manifest-alt'];
61+
$this->vasriManifest = $this->manifestReader->getManifest(base_path('vasri-manifest.json'));
62+
$this->appEnvironment = env('APP_ENV', 'production');
5763
}
5864

5965
/**
@@ -76,6 +82,8 @@ public function vasri(
7682
): string {
7783
if (self::isPublicFile($file)) {
7884

85+
$this->checkFileName($file);
86+
7987
return $this->addAttributes($file, $enableVersioning, $enableSRI, $keyword);
8088

8189
} else {
@@ -100,6 +108,18 @@ private function getSRI(string $file, string $keyword): string
100108
return sprintf('integrity="%s" %s', $this->vasriManifest[$file]['sri'], $this->builder->crossOrigin($keyword));
101109
}
102110

111+
/**
112+
* @param string $file
113+
*/
114+
private function checkFileName(string &$file): void
115+
{
116+
if ($this->isMixManifestAltEnabled) {
117+
118+
$file = $this->vasriManifest[$file]['alt'];
119+
120+
}
121+
}
122+
103123
/**
104124
* Builds all the attributes
105125
*

0 commit comments

Comments
 (0)