* [PATCH] www: redirect with query string
@ 2016-01-02 23:14 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-01-02 23:14 UTC (permalink / raw)
To: meta
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-01-02 23:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-02 23:14 [PATCH] www: redirect with query string Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).