allow subreddit links to get converted to old.reddit.com too
parent
e375e44645
commit
03b33deb26
|
@ -231,7 +231,7 @@ asset_image_link_regex = re.compile(f"https:\/\/(i\.)?{SITE}\/assets\/images\/[\
|
||||||
|
|
||||||
#sanitizing
|
#sanitizing
|
||||||
reddit_mention_regex = re.compile('(?<![\w/])\/?(([ruRU])\/[\w-]{2,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
reddit_mention_regex = re.compile('(?<![\w/])\/?(([ruRU])\/[\w-]{2,25})' + NOT_IN_CODE_OR_LINKS, flags=re.A)
|
||||||
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|www|new)\.reddit\.com|libredd\.it|reddit\.lol)\/(u|user|(r\/\w{2,25}\/)?comments)\/", flags=re.A)
|
reddit_domain_regex = re.compile("(^|\s|\()https?:\/\/(reddit\.com|(?:(?:[A-z]{2})(?:-[A-z]{2})" "?|www|new)\.reddit\.com|libredd\.it|reddit\.lol)\/(u\/|user\/|(r\/\w{2,25}\/)?comments\/|r\/\w{2,25}\/?$)", flags=re.A)
|
||||||
|
|
||||||
#gevent
|
#gevent
|
||||||
reddit_s_url_regex = re.compile("https:\/\/reddit.com\/r\/\w{2,25}\/s\/\w{10}", flags=re.A)
|
reddit_s_url_regex = re.compile("https:\/\/reddit.com\/r\/\w{2,25}\/s\/\w{10}", flags=re.A)
|
||||||
|
|
|
@ -742,7 +742,7 @@ def is_whitelisted(domain, k):
|
||||||
def normalize_url(url):
|
def normalize_url(url):
|
||||||
url = unquote(url)
|
url = unquote(url)
|
||||||
|
|
||||||
url = reddit_domain_regex.sub(r'\1https://old.reddit.com/\3/', url)
|
url = reddit_domain_regex.sub(r'\1https://old.reddit.com/\3', url)
|
||||||
|
|
||||||
url = url.replace("https://youtu.be/", "https://youtube.com/watch?v=") \
|
url = url.replace("https://youtu.be/", "https://youtube.com/watch?v=") \
|
||||||
.replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=") \
|
.replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=") \
|
||||||
|
|
Loading…
Reference in New Issue