From 9cb043b4cf9b273a170430b566135fde72d9ef55 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 28 Jan 2021 00:17:01 -0700 Subject: gmi2email: fix handling relative links Signed-off-by: Sean Whitton --- gmi2email | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gmi2email b/gmi2email index ef38426..f4a13a6 100755 --- a/gmi2email +++ b/gmi2email @@ -211,17 +211,13 @@ sub gemini_fetch { if ($meta =~ "^text/gemini") { my @lines; if ($opts{abs_links}) { - $path =~ s{^/}{}; - (my $dir = $path) =~ s{[^/]*$}{}; + my $dir = $path =~ s{[^/]*$}{}r =~ s{^/}{}r; $authority =~ m{/$} or $authority .= "/"; - $path =~ m{/$} or $path .= "/"; while (local $_ = <$cl>) { s/\r?\n\z//; - if (m{^=>\s*\./}) { + if (m{^=>\s*\./} || m{^=>\s*(?!/)} and not m{^=> [a-z]+://}) { push @lines, "=> gemini://$authority$dir$'"; - } elsif (m{^=> (?!/)} and not m{^=> [a-z]+://}) { - push @lines, "=> gemini://$authority$path$'"; - } elsif (m{^=> /}) { + } elsif (m{^=>\s*/}) { push @lines, "=> gemini://$authority$'"; } else { push @lines, $_; -- cgit v1.2.3