diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index af2a72a67..f5e51d204 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -788,12 +788,8 @@ def normalize_url(url): domain = tldextract.extract(netloc).registered_domain filtered |= {k: val for k, val in qd.items() if not val[0] or is_whitelisted(domain, k)} - hash = '' - if netloc == 'old.reddit.com': - x = reddit_comment_link_regex.search(url) - if x: - filtered['context'] = 8 - hash = x.group(1).replace('/', '#thing_t1_') + if netloc == 'old.reddit.com' and reddit_comment_link_regex.fullmatch(url): + filtered['context'] = 8 new_url = ParseResult(scheme="https", netloc=netloc, @@ -801,7 +797,7 @@ def normalize_url(url): params=parsed_url.params, query=urlencode(filtered, doseq=True), fragment=parsed_url.fragment) - url = urlunparse(new_url) + hash + url = urlunparse(new_url) domain = tldextract.extract(url).registered_domain