From eb2ff6434ee9ffe9354539186bbb7b8726788e0f Mon Sep 17 00:00:00 2001 From: David Phillips Date: Mon, 7 May 2018 21:17:47 +1200 Subject: Truncate URLs based on shorturl length, not full URL --- Plugin/URL_Title.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugin/URL_Title.pm b/Plugin/URL_Title.pm index 1d0056e..3297bed 100644 --- a/Plugin/URL_Title.pm +++ b/Plugin/URL_Title.pm @@ -71,12 +71,13 @@ sub message return unless $title; my $shorturl = $url; - $shorturl = (substr $url, 0, $config{url_len}) . "…" if length ($url) > $config{url_len}; - # remove http(s):// to avoid triggering other poorly configured bots $shorturl =~ s,^https?://,,g; $shorturl =~ s,/$,,g; + # truncate URL without http(s):// to configured length if needed + $shorturl = (substr $shorturl, 0, $config{url_len}) . "…" if length ($shorturl) > $config{url_len}; + my $composed_title = "$title ($shorturl)"; return $composed_title; } -- cgit v1.1