Exclude subdomain in Medium->Scribe redirects
Medium redirects needed further cleanup to account for instances where a link contains a subdomain that would not make sense in a Farside redirect link. Fixes #947main
parent
fab65d720d
commit
991fe6d910
|
@ -588,10 +588,9 @@ class Filter:
|
||||||
# replaced (i.e. 'philomedium.com' should stay as it is).
|
# replaced (i.e. 'philomedium.com' should stay as it is).
|
||||||
if 'medium.com' in link_str:
|
if 'medium.com' in link_str:
|
||||||
if link_str.startswith('medium.com') or '.medium.com' in link_str:
|
if link_str.startswith('medium.com') or '.medium.com' in link_str:
|
||||||
new_desc.string = link_str.replace(
|
link_str = 'farside.link/scribe' + link_str[
|
||||||
'medium.com', 'farside.link/scribe')
|
link_str.find('medium.com') + len('medium.com'):]
|
||||||
else:
|
new_desc.string = link_str
|
||||||
new_desc.string = link_str
|
|
||||||
else:
|
else:
|
||||||
new_desc.string = link_str.replace(site, alt)
|
new_desc.string = link_str.replace(site, alt)
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,8 @@ def get_site_alt(link: str) -> str:
|
||||||
if 'wikipedia' in hostname and len(subdomain) == 2:
|
if 'wikipedia' in hostname and len(subdomain) == 2:
|
||||||
hostname = f'{subdomain}.{hostname}'
|
hostname = f'{subdomain}.{hostname}'
|
||||||
params = f'?lang={subdomain}'
|
params = f'?lang={subdomain}'
|
||||||
|
elif 'medium' in hostname and len(subdomain) > 0:
|
||||||
|
hostname = f'{subdomain}.{hostname}'
|
||||||
|
|
||||||
parsed_alt = urlparse.urlparse(SITE_ALTS[site_key])
|
parsed_alt = urlparse.urlparse(SITE_ALTS[site_key])
|
||||||
link = link.replace(hostname, SITE_ALTS[site_key]) + params
|
link = link.replace(hostname, SITE_ALTS[site_key]) + params
|
||||||
|
|
Loading…
Reference in New Issue