Browse Source

Bug 27760: Improve readabiliity using map

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Jonathan Druart 2 years ago
parent
commit
25b08f9989
  1. 11
      Koha/REST/Plugin/Query.pm
  2. 6
      t/Koha/REST/Plugin/Query.t

11
Koha/REST/Plugin/Query.pm

@ -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 );

6
t/Koha/REST/Plugin/Query.t

@ -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
};

Loading…
Cancel
Save