unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 8/9] www: extra redirects for the '/'-challenged
Date: Fri,  4 Sep 2015 08:58:58 +0000	[thread overview]
Message-ID: <1441357139-23879-9-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1441357139-23879-1-git-send-email-e@80x24.org>

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


  parent reply	other threads:[~2015-09-04  8:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04  8:58 [PATCH 0/9] another round of updates Eric Wong
2015-09-04  8:58 ` [PATCH 1/9] view: eliminate redundant [threaded|flat] link Eric Wong
2015-09-04  8:58 ` [PATCH 2/9] view: one line for thread subjects Eric Wong
2015-09-04  8:58 ` [PATCH 3/9] view: adjust spacing and indentation of index threads Eric Wong
2015-09-04  8:58 ` [PATCH 4/9] view: add missing newline to inline dump Eric Wong
2015-09-04  8:58 ` [PATCH 5/9] view: reduce redundant attributions in permalink refs Eric Wong
2015-09-04  8:58 ` [PATCH 6/9] view: indentation adjustments for collapsed headers Eric Wong
2015-09-04  8:58 ` [PATCH 7/9] view: thread view expands focused message Eric Wong
2015-09-04  8:58 ` Eric Wong [this message]
2015-09-04  8:58 ` [PATCH 9/9] view: fix broken link to ghost fallback Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441357139-23879-9-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).