Skip to content

Commit

Permalink
Merge pull request #15 from ExoUNX/dev
Browse files Browse the repository at this point in the history
Added check on how to handle filename
  • Loading branch information
Gaige Lama authored Sep 15, 2019
2 parents 11fbb42 + 6e72493 commit 441bbb7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/ManifestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ private function loopManifest(array $mixManifest, array &$vasriManifest = []): v
if ($this->isMixManifestAltEnabled) {

foreach ($mixManifest as $key => $val) {
$vasriManifest[] = $val;
$vasriManifest[] = [
$key => [
'alt' => $val
]
];
}

} else {
Expand Down
30 changes: 25 additions & 5 deletions src/Vasri.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ class Vasri
*/
private $vasriConfig;

/**
* @var
*/
private $isMixManifestAltEnabled;

/**
* Vasri constructor.
*/
public function __construct()
{
$this->builder = new Builder();
$this->manifestReader = new ManifestReader();
$this->vasriConfig = config('vasri');
$this->vasriManifest = $this->manifestReader->getManifest(base_path('vasri-manifest.json'));
$this->appEnvironment = env('APP_ENV', 'production');
$this->builder = new Builder();
$this->manifestReader = new ManifestReader();
$this->vasriConfig = config('vasri');
$this->isMixManifestAltEnabled = $this->vasriConfig['mix-manifest-alt'];
$this->vasriManifest = $this->manifestReader->getManifest(base_path('vasri-manifest.json'));
$this->appEnvironment = env('APP_ENV', 'production');
}

/**
Expand All @@ -76,6 +82,8 @@ public function vasri(
): string {
if (self::isPublicFile($file)) {

$this->checkFileName($file);

return $this->addAttributes($file, $enableVersioning, $enableSRI, $keyword);

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

/**
* @param string $file
*/
private function checkFileName(string &$file): void
{
if ($this->isMixManifestAltEnabled) {

$file = $this->vasriManifest[$file]['alt'];

}
}

/**
* Builds all the attributes
*
Expand Down

0 comments on commit 441bbb7

Please sign in to comment.