summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2021-01-04 13:13:54 +0100
committerYorhel <git@yorhel.nl>2021-01-04 13:13:54 +0100
commitf78f37e369567c91896aeeb505e706df4b4c12ff (patch)
tree35191aced9be7e253482740361158bc9679b081e
parent9b8550483df34a4f711e694071d88c033f440a0f (diff)
VN::List: Handle old firstchar-filter URLs + redirect on single result
-rw-r--r--lib/VNWeb/VN/List.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/VNWeb/VN/List.pm b/lib/VNWeb/VN/List.pm
index d440b2fe..8445efed 100644
--- a/lib/VNWeb/VN/List.pm
+++ b/lib/VNWeb/VN/List.pm
@@ -44,7 +44,7 @@ sub listing_ {
}
-TUWF::get qr{/experimental/v}, sub {
+TUWF::get qr{/experimental/v(?:/(?<char>all|[a-z0]))?}, sub {
my $opt = tuwf->validate(get =>
q => { onerror => undef },
sq=> { onerror => undef },
@@ -59,6 +59,7 @@ TUWF::get qr{/experimental/v}, sub {
)->data;
$opt->{q} //= $opt->{sq};
$opt->{ch} = $opt->{ch}[0];
+ $opt->{ch} //= tuwf->capture('char') if tuwf->capture('char') ne 'all'; # compat with old URLs
# URL compatibility with old filters
if(!$opt->{f}->{query} && ($opt->{fil} || $opt->{rfil} || $opt->{cfil})) {
@@ -124,6 +125,8 @@ TUWF::get qr{/experimental/v}, sub {
}
die $@ if !defined $list;
+ return tuwf->resRedirect("/v$list->[0]{id}") if $count == 1 && $opt->{q} && !defined $opt->{ch};
+
enrich_flatten vnlist_labels => id => vid => sub { sql '
SELECT uvl.vid, ul.label
FROM ulist_vns_labels uvl