Sometimes users will write "http://example.com" without the
trailing slash, which every browser and tool I've tested seems
to understand.
my $SALT = rand;
my $LINK_RE = qr{(\()?\b((?:ftps?|https?|nntps?|gopher)://
- [\@:\w\.-]+/
+ [\@:\w\.-]+(?:/
(?:[a-z0-9\-\._~!\$\&\';\(\)\*\+,;=:@/%]*)
(?:\?[a-z0-9\-\._~!\$\&\';\(\)\*\+,;=:@/%]+)?
(?:\#[a-z0-9\-\._~!\$\&\';\(\)\*\+,;=:@/%\?]+)?
- )}xi;
+ )?
+ )}xi;
sub new { bless {}, $_[0] }
is($s, qq(<a\nhref="$u">$u</a>.), 'trailing period not in URL');
}
+{
+ my $l = PublicInbox::Linkify->new;
+ my $u = 'http://i-forgot-trailing-slash.example.com';
+ my $s = $u;
+ $s = $l->linkify_1($s);
+ $s = $l->linkify_2($s);
+ is($s, qq(<a\nhref="$u">$u</a>), 'missing trailing slash OK');
+}
+
# handle URLs in parenthesized statements
{
my $l = PublicInbox::Linkify->new;