www: Fix search redirect if no section is specified

i.e. let the man_pref logic determine the most useful section, instead
of forcing the first relevant section in the redirect.
This commit is contained in:
Yorhel 2024-04-29 11:31:26 +02:00
parent 9a81147983
commit 962a7c848a

View file

@ -602,7 +602,7 @@ TUWF::get '/browse/search' => sub {
# Redirect if we have an exact match
my @sectsql = length $sect ? ('AND section =', \$sect) : ();
my $man = length $name && tuwf->dbRowi('SELECT name, section FROM mans WHERE name =', \$name, @sectsql);
return tuwf->resRedirect("/man/$man->{name}.$man->{section}", 'temp') if length $man->{name};
return tuwf->resRedirect("/man/$man->{name}".(length $sect ? ".$man->{section}" : ''), 'temp') if length $man->{name};
# Otherwise, do case-insensitive glob search
my $nameq = escape_like(lc $name) =~ tr/?*/_%/r;