]> Sergey Matveev's repositories - public-inbox.git/commitdiff
linkify: match more URL characters [:,\$] and schemes
authorEric Wong <e@80x24.org>
Sun, 1 May 2016 01:54:07 +0000 (01:54 +0000)
committerEric Wong <e@80x24.org>
Sun, 1 May 2016 02:06:17 +0000 (02:06 +0000)
Adding ':' (colon), ',' (comma), '$' (dollar sign) and
supporting TLS-enabled schemes: ftps, nntps variants as
well as gopher :D

lib/PublicInbox/Linkify.pm

index 49ab311689751eacc704c292270abf93e6a03107..25f0b48a34d9b2329b97d857797476f474e7632a 100644 (file)
@@ -15,9 +15,9 @@ use warnings;
 use Digest::SHA qw/sha1_hex/;
 
 my $SALT = rand;
-my $LINK_RE = qr!\b((?:ftp|https?|nntp)://
+my $LINK_RE = qr!\b((?:ftps?|https?|nntps?|gopher)://
                 [\@:\w\.-]+/
-                ?[~\@\w\+\&\?\.\%\;/#=-]*)!x;
+                ?[,:~\$\@\w\+\&\?\.\%\;/#=-]*)!x;
 
 sub new { bless {}, shift }
 
@@ -28,8 +28,10 @@ sub linkify_1 {
                my $end = '';
 
                # it's fairly common to end URLs in messages with
-               # '.' or ';' to denote the end of a statement.
-               if ($url =~ s/(\.)\z// || $url =~ s/(;)\z//) {
+               # '.', ',' or ';' to denote the end of a statement;
+               # assume the intent was to end the statement/sentence
+               # in English
+               if ($url =~ s/([\.,;])\z//) {
                        $end = $1;
                }