chore: add Laravel excluded paths option

This commit is contained in:
Younes ENNAJI
2024-10-20 15:00:48 +01:00
parent 16c1764e73
commit 095b0d967d
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -227,10 +227,13 @@ final class FlasherServiceProvider extends PluginServiceProvider
} }
$this->app->singleton(FlasherMiddleware::class, static function (Application $app) { $this->app->singleton(FlasherMiddleware::class, static function (Application $app) {
$config = $app->make('config');
$flasher = $app->make('flasher'); $flasher = $app->make('flasher');
$cspHandler = $app->make('flasher.csp_handler'); $cspHandler = $app->make('flasher.csp_handler');
$excludedPaths = $config->get('flasher.excluded_paths', []) ?: [];
return new FlasherMiddleware(new ResponseExtension($flasher, $cspHandler)); return new FlasherMiddleware(new ResponseExtension($flasher, $cspHandler, $excludedPaths));
}); });
$this->pushMiddlewareToGroup(FlasherMiddleware::class); $this->pushMiddlewareToGroup(FlasherMiddleware::class);
@@ -13,6 +13,7 @@ namespace Illuminate\Contracts\Config;
* scripts: string[], * scripts: string[],
* styles: string[], * styles: string[],
* options: array<string, mixed>, * options: array<string, mixed>,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>, * filter: array<string, mixed>,
* flash_bag: array<string, string[]>, * flash_bag: array<string, string[]>,
* presets: array<string, PresetType>, * presets: array<string, PresetType>,
@@ -44,6 +45,7 @@ interface Repository
* ($key is 'flasher.presets' ? array<string, PresetType> : * ($key is 'flasher.presets' ? array<string, PresetType> :
* ($key is 'flasher.plugins' ? array<string, PluginType> : * ($key is 'flasher.plugins' ? array<string, PluginType> :
* ($key is 'flasher.flash_bag' ? array<string, string[]> : * ($key is 'flasher.flash_bag' ? array<string, string[]> :
* ($key is 'flasher.excluded_paths' ? list<non-empty-string> :
* mixed))))))) * mixed)))))))
*/ */
public function get(string|array $key, mixed $default = null): mixed; public function get(string|array $key, mixed $default = null): mixed;