about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-09-10 20:10:23 +0000
committerEric Wong <e@80x24.org>2022-09-11 19:25:46 +0000
commitf5e2daa70e0a1a75d1220d84193f3eeebb799c38 (patch)
treef5a5a8bcf8982ab5b025f8070011e099eeb55cab /lib/PublicInbox/View.pm
parent12900fecdc4c7f577eb8266a2334d74f72fd2518 (diff)
downloadpublic-inbox-f5e2daa70e0a1a75d1220d84193f3eeebb799c38.tar.gz
For redundant messages sharing Message-IDs, the link to solver
(/$INBOX/$OID/s/) was going up too many levels for /$INBOX/$MSGID/
when there were multiple messages sharing the same $MSGID.

Unfortunately, redundant messages are common with /all/
due to signature trailers.  So dynamically assigning {-spfx}
is tricky and error prone from counting `/'.

So simplify the code a bit by setting {-spfx} once per HTTP
request, instead of every single message.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm20
1 files changed, 2 insertions, 18 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 0753c06e..01c086bf 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -80,6 +80,7 @@ sub msg_page {
         # allow user to easily browse the range around this message if
         # they have ->over
         $ctx->{-t_max} = $smsg->{ts};
+        $ctx->{-spfx} = '../' if $ibx->{coderepo};
         PublicInbox::WwwStream::aresponse($ctx, \&msg_page_i);
 }
 
@@ -441,6 +442,7 @@ sub thread_html {
         my $ibx = $ctx->{ibx};
         my ($nr, $msgs) = $ibx->over->get_thread($mid);
         return missing_thread($ctx) if $nr == 0;
+        $ctx->{-spfx} = '../../' if $ibx->{coderepo};
 
         # link $INBOX_DIR/description text to "index_topics" view around
         # the newest message in this thread
@@ -584,24 +586,6 @@ sub add_text_body { # callback for each_part
                 $ctx->{-anchors} = {} if $s =~ /^diff --git /sm;
                 $diff = 1;
                 delete $ctx->{-long_path};
-                my $spfx;
-                # absolute URL (Atom feeds)
-                if ($ibx->{coderepo}) {
-                        if (index($upfx, '//') >= 0) {
-                                $spfx = $upfx;
-                                $spfx =~ s!/([^/]*)/\z!/!;
-                        } else {
-                                my $n_slash = $upfx =~ tr!/!/!;
-                                if ($n_slash == 0) {
-                                        $spfx = '../';
-                                } elsif ($n_slash == 1) {
-                                        $spfx = '';
-                                } else { # nslash == 2
-                                        $spfx = '../../';
-                                }
-                        }
-                }
-                $ctx->{-spfx} = $spfx;
         };
 
         # split off quoted and unquoted blocks: