about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/Linkify.pm5
-rw-r--r--t/linkify.t9
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/PublicInbox/Linkify.pm b/lib/PublicInbox/Linkify.pm
index 274f3820..aa472cdb 100644
--- a/lib/PublicInbox/Linkify.pm
+++ b/lib/PublicInbox/Linkify.pm
@@ -16,11 +16,12 @@ use Digest::SHA qw/sha1_hex/;
 
 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] }
 
diff --git a/t/linkify.t b/t/linkify.t
index a55ed22a..f0b3a6d0 100644
--- a/t/linkify.t
+++ b/t/linkify.t
@@ -14,6 +14,15 @@ use PublicInbox::Linkify;
         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;