]> Sergey Matveev's repositories - public-inbox.git/commitdiff
view: fix broken hunk header hrefs in Atom feeds
authorEric Wong <e@80x24.org>
Fri, 1 Feb 2019 01:47:31 +0000 (01:47 +0000)
committerEric Wong <e@80x24.org>
Fri, 1 Feb 2019 01:49:39 +0000 (01:49 +0000)
We use absolute URLs in the Atom feeds (to ease
syndication/mirroring), so hunk headers need to point to the
solver URLs.

lib/PublicInbox/View.pm

index 8c8125369a69eb2b3e5961b5258a5c2056725f9a..782e66861742ad376785e0199aaa8157aee7762a 100644 (file)
@@ -573,13 +573,18 @@ sub add_text_body {
                $ctx->{-diff} = $diff = [];
                my $spfx;
                if ($ibx->{-repo_objs}) {
-                       my $n_slash = $upfx =~ tr!/!/!;
-                       if ($n_slash == 0) {
-                               $spfx = '../';
-                       } elsif ($n_slash == 1) {
-                               $spfx = '';
-                       } else { # nslash == 2
-                               $spfx = '../../';
+                       if (index($upfx, '//') >= 0) { # absolute URL (Atom feeds)
+                               $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;