From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.5 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD,URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E649220202 for ; Sat, 2 Jan 2016 23:14:58 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] www: redirect with query string Date: Sat, 2 Jan 2016 23:14:58 +0000 Message-Id: <20160102231458.32217-1-e@80x24.org> List-Id: We use query strings for search and index pages, so we should not drop them if somebody types a URL by hand and omits the trailing slash. --- lib/PublicInbox/WWW.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index ee414e8..b4c050b 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -358,15 +358,19 @@ sub r301 { my ($ctx, $listname, $mid, $suffix) = @_; my $cgi = $ctx->{cgi}; my $url; + my $qs; if (ref($cgi) eq 'CGI') { $url = $cgi->url(-base) . '/'; + $qs = $cgi->query_string; } else { $url = $cgi->base->as_string; + $qs = $cgi->env->{QUERY_STRING}; } $url .= $listname . '/'; $url .= (uri_escape_utf8($mid) . '/') if (defined $mid); $url .= $suffix if (defined $suffix); + $url .= "?$qs" if $qs ne ''; [ 301, [ Location => $url, 'Content-Type' => 'text/plain' ], -- EW