user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] www: redirect with query string
@ 2016-01-02 23:14  7% Eric Wong
  0 siblings, 0 replies; 1+ results
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	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-01-02 23:14  7% [PATCH] www: redirect with query string Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).