From 6c365b8fba7cf8423a81e495a73c3b7c52ea0797 Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 15 Aug 2019 19:19:21 +0200 Subject: [PATCH] Include 'www.' in twitter/youtube link replacement --- src/formatters.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/formatters.nim b/src/formatters.nim index 920301c..6c68425 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -11,8 +11,8 @@ const usernameRegex = re"(^|[^A-z0-9_?])@([A-z0-9_]+)" picRegex = re"pic.twitter.com/[^ ]+" ellipsisRegex = re" ?…" - ytRegex = re"youtu(be.com|.be)" - twRegex = re"twitter.com" + ytRegex = re"(www.)?youtu(be.com|.be)" + twRegex = re"(www.)?twitter.com" nbsp = $Rune(0x000A0) proc stripText*(text: string): string = @@ -65,9 +65,9 @@ proc linkifyText*(text: string; prefs: Prefs): string = proc replaceUrl*(url: string; prefs: Prefs): string = result = url if prefs.replaceYouTube.len > 0: - result = url.replace(ytRegex, prefs.replaceYouTube) + result = result.replace(ytRegex, prefs.replaceYouTube) if prefs.replaceTwitter.len > 0: - result = url.replace(twRegex, prefs.replaceTwitter) + result = result.replace(twRegex, prefs.replaceTwitter) proc stripTwitterUrls*(text: string): string = result = text