diff --git a/files/classes/comment.py b/files/classes/comment.py index 1f002e8838..3a804f0518 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -21,8 +21,11 @@ def normalize_urls_runtime(body, v): if v and v.reddit != 'old.reddit.com': body = reddit_to_vreddit_regex.sub(rf'\1https://{v.reddit}/\2/', body) - if v.nitter: body = twitter_to_nitter_regex.sub(r'https://nitter.42l.fr/\1', body) - if v.imginn: body = body.replace('https://instagram.com/', 'https://imginn.com/') + if v.nitter: + body = body.replace('https://twitter.com/', 'https://nitter.42l.fr/') + body = body.replace('https://nitter.42l.fr/i/', 'https://twitter.com/i/') + if v.imginn: + body = body.replace('https://instagram.com/', 'https://imginn.com/') return body diff --git a/files/helpers/regex.py b/files/helpers/regex.py index 108ae0cf19..90849a2318 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -90,8 +90,6 @@ greentext_regex = re.compile("(\n|^)>([^ >][^\n]*)", flags=re.A) ascii_only_regex = re.compile("[ -~]+", flags=re.A) -twitter_to_nitter_regex = re.compile("https:\/\/twitter.com\/(\w{2,15}(\/status\/\d+[^/]*)?)", flags=re.A) - reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/(r|u)\/', flags=re.A) reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|new\.reddit.com|www\.reddit.com|i\.reddit\.com|libredd\.it|teddit\.net)\/(r|u)\/", flags=re.A)