summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-01-28 00:17:01 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-01-28 00:17:01 -0700
commit9cb043b4cf9b273a170430b566135fde72d9ef55 (patch)
tree7d819e35a8a651c4791316fb5588cffa5258a224
parentf42d49b2939ab6983271a7ecdcf16a996f6ebeac (diff)
downloadmailscripts-9cb043b4cf9b273a170430b566135fde72d9ef55.tar.gz
gmi2email: fix handling relative links
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-xgmi2email10
1 files 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, $_;