Skip to content

Commit

Permalink
Merge pull request #11 from ExoUNX/dev
Browse files Browse the repository at this point in the history
Fix config loading issue
  • Loading branch information
Gaige Lama authored Sep 8, 2019
2 parents 272364d + abcb0ce commit 76939a1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ php artisan vendor:publish --provider="ExoUNX\Vasri\Providers\VasriServiceProvid

Note: If you use a CDN like Cloudflare that processes your assets at their edge servers, I recommend you disable it and process your scripts beforehand otherwise resources may not load

You'll need to generate the manifest first by running the following command
You'll need to generate the manifest first and every time the assets change

```
php artisan vasri:build
Expand Down
10 changes: 5 additions & 5 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public function sri(string $file): string
{
$algorithm = self::selectAlgorithm();

return $algorithm.'-'.base64_encode(
hash_file($algorithm, public_path($file), true)
);
return sprintf('%s-%s', $algorithm, base64_encode(
hash_file($algorithm, public_path($file), true)
));
}

/**
Expand All @@ -59,7 +59,7 @@ public function sri(string $file): string
*/
public function versioning(string $file): string
{
return '?id='.hash_file('md5', public_path($file));
return sprintf('?id=%s', hash_file('md5', public_path($file)));
}

/**
Expand Down Expand Up @@ -100,7 +100,7 @@ public function attribute(string $file): string
*/
public function crossOrigin(string $keyword): string
{
return 'crossorigin="'.$keyword.'"';
return sprintf('crossorigin="%s"', $keyword);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ManifestReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getManifest(string $file): array

} else {

throw new Exception('Incorrect file path or file does not exist for '.$file);
throw new Exception("Incorrect file path or file does not exist for $file");

}
}
Expand Down
5 changes: 2 additions & 3 deletions src/Providers/VasriServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ public function boot(): void
*/
public function register()
{
$this->mergeConfigFrom(
base_path('/config/vasri.php'), 'vasri'
);
$this->commands([
\ExoUNX\Vasri\Commands\VasriCommand::class,
]);

$this->mergeConfigFrom(__DIR__.'/../config/vasri.php', 'vasri');
}

}
7 changes: 4 additions & 3 deletions src/Vasri.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function vasri(
*/
private function getSRI(string $file, string $keyword): string
{
return ' integrity="'.$this->vasriManifest[$file]['sri'].'" '.$this->builder->crossOrigin($keyword);

return sprintf('integrity="%s" %s', $this->vasriManifest[$file]['sri'], $this->builder->crossOrigin($keyword));
}

/**
Expand All @@ -110,7 +111,7 @@ private function addAttributes(string $file, bool $enableVersioning, bool $enabl
}
if ($enableSRI) {

$output .= $this->getSRI($file, $keyword);
$output = sprintf('%s %s', $output, $this->getSRI($file, $keyword));

}

Expand All @@ -136,7 +137,7 @@ private function getVersioning(string $file): string
*/
private function getSourceAttribute(string $file, string $version = ''): string
{
return $this->builder->attribute($file).'="'.$file.$version.'"';
return sprintf('%s="%s%s"', $this->builder->attribute($file), $file, $version);
}

/**
Expand Down

0 comments on commit 76939a1

Please sign in to comment.