From 472d39de46603b180ab6e739e0b31ab7ef559870 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 1 Mar 2016 03:44:04 +0000 Subject: linkify: do not capture trailing '.' or ';' in URLs It seems common for users to end statements with URLs, while it is rare for a URL itself to end with a '.' or ';'. So make a guess and assume the URL was intended to not include the trailing '.' or ';' --- t/linkify.t | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 t/linkify.t (limited to 't/linkify.t') diff --git a/t/linkify.t b/t/linkify.t new file mode 100644 index 00000000..586691ae --- /dev/null +++ b/t/linkify.t @@ -0,0 +1,26 @@ +# Copyright (C) 2016 all contributors +# License: AGPL-3.0+ +use strict; +use warnings; +use Test::More; +use PublicInbox::Linkify; + +{ + my $l = PublicInbox::Linkify->new; + my $u = 'http://example.com/url-with-trailing-period'; + my $s = $u . '.'; + $s = $l->linkify_1($s); + $s = $l->linkify_2($s); + is($s, qq($u.), 'trailing period not in URL'); +} + +{ + my $l = PublicInbox::Linkify->new; + my $u = 'http://example.com/url-with-trailing-semicolon'; + my $s = $u . ';'; + $s = $l->linkify_1($s); + $s = $l->linkify_2($s); + is($s, qq($u;), 'trailing semicolon not in URL'); +} + +done_testing(); -- cgit v1.2.3-24-ge0c7