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 8/9] www: extra redirects for the '/'-challenged
  @ 2015-09-04  8:58  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2015-09-04  8:58 UTC (permalink / raw)
  To: meta

Omitting a slash should not be fatal if unambiguous.  Add
fallbacks so users who expect a directory structure-like
experience can have it at the cost of one extra HTTP
request/response pair.

This matches behavior of static sites.
---
 lib/PublicInbox/WWW.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e8b35cb..5584e49 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -42,6 +42,10 @@ sub run {
 	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/$END_RE\z!o) {
 		msg_page($ctx, $1, $2, $3);
 
+	# in case people leave off the trailing slash:
+	} elsif ($path_info =~ m!$LISTNAME_RE/$MID_RE/(f|T|t)\z!o) {
+		r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3);
+
 	# convenience redirects order matters
 	} elsif ($path_info =~ m!$LISTNAME_RE/([^/]{2,})\z!o) {
 		r301($ctx, $1, $2);
@@ -354,6 +358,9 @@ sub legacy_redirects {
 	} elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/$END_RE\z!o) {
 		msg_page($ctx, $1, $2, $3);
 
+	# in case people leave off the trailing slash:
+	} elsif ($path_info =~ m!$LISTNAME_RE/(\S+/\S+)/(f|T|t)\z!o) {
+		r301($ctx, $1, $2, $3 eq 't' ? 't/#u' : $3);
 	} else {
 		r404();
 	}
-- 
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 --
2015-09-04  8:58     [PATCH 0/9] another round of updates Eric Wong
2015-09-04  8:58  7% ` [PATCH 8/9] www: extra redirects for the '/'-challenged 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).