Sometimes, URLs exist at the end of parethesized statements,
and we shouldn't unnecessarily capture that.
(example: https://public-inbox.org/ruby-core/
20170623032722.GA8124@dcvr/)
sub new { bless {}, $_[0] }
sub linkify_1 {
- $_[1] =~ s!$LINK_RE!
+ $_[1] =~ s^$LINK_RE^
my $beg = $1 || '';
my $url = $2;
my $end = '';
}
} elsif ($url =~ s/([\.,;])\z//) {
$end = $1;
+ } elsif ($url !~ /\(/ && $url =~ s/\)\z//) {
+ $end = ')';
}
# salt this, as this could be exploited to show
$url =~ s/&/&/g;
$_[0]->{$key} = $url;
$beg . 'PI-LINK-'. $key . $end;
- !ge;
+ ^ge;
$_[1];
}
is($s, qq(<a\nhref="$u">$u</a>.), 'trailing period not in URL');
}
+# handle URLs in parenthesized statements
+{
+ my $l = PublicInbox::Linkify->new;
+ my $u = 'http://example.com/';
+ my $s = "(see: $u)";
+ $s = $l->linkify_1($s);
+ $s = $l->linkify_2($s);
+ is($s, qq{(see: <a\nhref="$u">$u</a>)}, 'trailing ) not in URL');
+}
+
{
my $l = PublicInbox::Linkify->new;
my $u = 'http://example.com/url-with-trailing-semicolon';