about summary refs log tree commit homepage
path: root/lib/PublicInbox/WWW.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-09-04 08:49:29 +0000
committerEric Wong <e@80x24.org>2015-09-04 08:49:29 +0000
commit6e509b610078e6758b98d1151ea775f76fd22cbe (patch)
treec9a87f71fb27e5d4c4f6af631dd7f9512eced68d /lib/PublicInbox/WWW.pm
parent239d316f953260768f36f95006c919e45c0dd8e8 (diff)
downloadpublic-inbox-6e509b610078e6758b98d1151ea775f76fd22cbe.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/WWW.pm')
-rw-r--r--lib/PublicInbox/WWW.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e8b35cb2..5584e49b 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();
         }