From 1e03323d76eb6c029ab6749fe783f25d5d109e1f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 1 Feb 2019 01:47:31 +0000 Subject: view: fix broken hunk header hrefs in Atom feeds 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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/View.pm') diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 8c812536..782e6686 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -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; -- cgit v1.2.3-24-ge0c7