Bug 27760: Improve readabiliity using map

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-03-11 11:15:26 +01:00
parent 91ce8a098c
commit 25b08f9989
2 changed files with 7 additions and 10 deletions

View file

@ -277,16 +277,9 @@ Merges parameters from $q_params into $filtered_params.
my ( $c ) = @_;
my $override_header = $c->req->headers->header('x-koha-override');
my $override_header = $c->req->headers->header('x-koha-override') || q{};
my $overrides = {};
if ( $override_header ) {
my @overrides = ();
foreach my $override ( split /\s*,\s*/, $override_header ) {
$overrides->{$override} = 1;
}
}
my $overrides = { map { $_ => 1 } split /\s*,\s*/, $override_header };
$c->stash( 'koha.overrides' => $overrides );

View file

@ -502,7 +502,7 @@ subtest 'stash_embed() tests' => sub {
subtest 'stash_overrides() tests' => sub {
plan tests => 4;
plan tests => 6;
my $t = Test::Mojo->new;
@ -511,4 +511,8 @@ subtest 'stash_overrides() tests' => sub {
$t->get_ok( '/stash_overrides' => { 'x-koha-override' => '' } )
->json_is( {} ); # empty string is skipped
$t->get_ok( '/stash_overrides' => { } )
->json_is( {} ); # x-koha-ovverride not passed is skipped
};