From eff0b55740d15c420fd8e6092dd9ca321edf1e1d Mon Sep 17 00:00:00 2001 From: Gaige Lama Date: Sat, 7 Sep 2019 20:56:16 -0400 Subject: [PATCH 1/3] Fixed service provider register issue and kept to sprintf() Signed-off-by: Gaige Lama --- src/Builder.php | 10 +++++----- src/ManifestReader.php | 2 +- src/Providers/VasriServiceProvider.php | 2 +- src/Vasri.php | 7 ++++--- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Builder.php b/src/Builder.php index 26fae4e..7adb67e 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -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) + )); } /** @@ -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))); } /** @@ -100,7 +100,7 @@ public function attribute(string $file): string */ public function crossOrigin(string $keyword): string { - return 'crossorigin="'.$keyword.'"'; + return sprintf('crossorigin="%s"', $keyword); } /** diff --git a/src/ManifestReader.php b/src/ManifestReader.php index 419f434..f9df491 100644 --- a/src/ManifestReader.php +++ b/src/ManifestReader.php @@ -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"); } } diff --git a/src/Providers/VasriServiceProvider.php b/src/Providers/VasriServiceProvider.php index 34fc8e0..8dde269 100644 --- a/src/Providers/VasriServiceProvider.php +++ b/src/Providers/VasriServiceProvider.php @@ -39,7 +39,7 @@ public function boot(): void public function register() { $this->mergeConfigFrom( - base_path('/config/vasri.php'), 'vasri' + base_path('/../config/vasri.php'), 'vasri' ); $this->commands([ \ExoUNX\Vasri\Commands\VasriCommand::class, diff --git a/src/Vasri.php b/src/Vasri.php index 237218e..756080a 100644 --- a/src/Vasri.php +++ b/src/Vasri.php @@ -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)); } /** @@ -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)); } @@ -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); } /** From a37dae56dc71d9566cf410a66533a7d0e015c539 Mon Sep 17 00:00:00 2001 From: Gaige Lama Date: Sat, 7 Sep 2019 22:13:04 -0400 Subject: [PATCH 2/3] Fixing config issue with Service provider Signed-off-by: Gaige Lama --- src/Providers/VasriServiceProvider.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Providers/VasriServiceProvider.php b/src/Providers/VasriServiceProvider.php index 8dde269..8b68ce2 100644 --- a/src/Providers/VasriServiceProvider.php +++ b/src/Providers/VasriServiceProvider.php @@ -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'); } } From abcb0ce727def291cf13bc20371a91c4269c9cec Mon Sep 17 00:00:00 2001 From: Gaige Lama Date: Sat, 7 Sep 2019 22:15:12 -0400 Subject: [PATCH 3/3] Updating documentation Signed-off-by: Gaige Lama --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77f4da5..c576a41 100644 --- a/README.md +++ b/README.md @@ -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