diff options
author | Eric Wong <e@80x24.org> | 2020-12-22 05:04:16 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-12-22 22:56:06 +0000 |
commit | 37526779e4c544b134af74f43d6c26569cb8e466 (patch) | |
tree | 15315f4e24230e6729b437faaa1ba314ea91f9bf /lib | |
parent | 949e8b4a65a2dbb99d8923ebb4715a8724ca8bf2 (diff) | |
download | public-inbox-37526779e4c544b134af74f43d6c26569cb8e466.tar.gz |
Trying to link "foo.git" relative to the current URL usually does not provide correct results, so prefix it by going into the parent directory if an absolute (or protocol-relative) URL is not supplied.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/WwwStream.pm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 9ba8fa11..958251a3 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -81,13 +81,17 @@ sub coderepos ($) { my ($ctx) = @_; my $cr = $ctx->{ibx}->{coderepo} // return (); my $cfg = $ctx->{www}->{pi_cfg}; + my $upfx = ($ctx->{-upfx} // ''). '../'; my @ret; for my $cr_name (@$cr) { my $urls = $cfg->{"coderepo.$cr_name.cgiturl"} // next; $ret[0] //= <<EOF; code repositories for the project(s) associated with this inbox: EOF - for my $u (@$urls) { + for (@$urls) { + # relative or absolute URL?, prefix relative "foo.git" + # with appropriate number of "../" + my $u = m!\A(?:[a-z\+]+:)?//! ? $_ : $upfx.$_; $u = ascii_html(prurl($ctx->{env}, $u)); $ret[0] .= qq(\n\t<a\nhref="$u">$u</a>); } |