As with our use of the trailing slash in $MESSAGE_ID/T/ and
'$MESSAGE_ID/t/' endpoints, this for 'wget -r --mirror'
compatibility as well as allowing sysadmins to quickly stand up
a static directory with "index.html" in it to reduce load.
---
 lib/PublicInbox/ViewDiff.pm | 8 ++++----
 lib/PublicInbox/ViewVCS.pm  | 4 ++--
 lib/PublicInbox/WWW.pm      | 6 ++++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 94f015f..1aad283 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -45,12 +45,12 @@ sub diff_hunk ($$$$) {
        my ($n) = ($ca =~ /^-(\d+)/);
        $n = defined($n) ? do { ++$n; "#n$n" } : '';
 
-       my $rv = qq(@@ <a\nhref=$spfx$oid_a/s$dctx->{Q}$n>$ca</a>);
+       my $rv = qq(@@ <a\nhref=$spfx$oid_a/s/$dctx->{Q}$n>$ca</a>);
 
        ($n) = ($cb =~ /^\+(\d+)/);
        $n = defined($n) ? do { ++$n; "#n$n" } : '';
 
-       $rv .= qq( <a\nhref=$spfx$oid_b/s$dctx->{Q}$n>$cb</a> @@);
+       $rv .= qq( <a\nhref=$spfx$oid_b/s/$dctx->{Q}$n>$cb</a> @@);
 }
 
 sub flush_diff ($$$$) {
@@ -90,11 +90,11 @@ sub flush_diff ($$$$) {
                        }
                        $$dst .= to_html($linkify, $s);
                } elsif ($s =~ s/^(index $OID_NULL\.\.)($OID_BLOB)\b//o) {
-                       $$dst .= qq($1<a\nhref=$spfx$2/s$dctx->{Q}>$2</a>);
+                       $$dst .= qq($1<a\nhref=$spfx$2/s/$dctx->{Q}>$2</a>);
                        $$dst .= to_html($linkify, $s) ;
                } elsif ($s =~ s/^index ($OID_NULL)(\.\.$OID_BLOB)\b//o) {
                        $$dst .= 'index ';
-                       $$dst .= qq(<a\nhref=$spfx$1/s$dctx->{Q}>$1</a>$2);
+                       $$dst .= qq(<a\nhref=$spfx$1/s/$dctx->{Q}>$1</a>$2);
                        $$dst .= to_html($linkify, $s);
                } elsif ($s =~ /^index ($OID_BLOB)\.\.($OID_BLOB)/o) {
                        $dctx->{oid_a} = $1;
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 90c0907..61f4deb 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -27,7 +27,7 @@ my $enc_utf8 = find_encoding('UTF-8');
 
 sub html_page ($$$) {
        my ($ctx, $code, $strref) = @_;
-       $ctx->{-upfx} = '../'; # from "/$INBOX/$OID/s"
+       $ctx->{-upfx} = '../../'; # from "/$INBOX/$OID/s/"
        PublicInbox::WwwStream->response($ctx, $code, sub {
                my ($nr, undef) =  @_;
                $nr == 1 ? $$strref : undef;
@@ -82,7 +82,7 @@ sub show ($$;$) {
        }
 
        my $path = to_filename($di->{path_b} || $hints->{path_b} || 'blob');
-       my $raw_link = "(<a\nhref=_$path>raw</a>)";
+       my $raw_link = "(<a\nhref=$path>raw</a>)";
        if ($binary) {
                $log = "<pre>$oid $type $size bytes (binary)" .
                        " $raw_link</pre>" . $log;
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index c73370f..a0fd7fa 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -118,10 +118,12 @@ sub call {
                r301($ctx, $1, $2);
        } elsif ($path_info =~ m!$INBOX_RE/_/text(?:/(.*))?\z!o) {
                get_text($ctx, $1, $2);
-       } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s\z!o) {
+       } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s/\z!o) {
                get_vcs_object($ctx, $1, $2);
-       } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/_([\w\.\-]+)\z!o) {
+       } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s/([\w\.\-]+)\z!o) {
                get_vcs_object($ctx, $1, $2, $3);
+       } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s\z!o) {
+               r301($ctx, $1, $2, 's/');
        # convenience redirects order matters
        } elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
                r301($ctx, $1, $2);
-- 
EW

--
unsubscribe: [email protected]
archive: https://public-inbox.org/meta/

Reply via email to