Fix getting the instance domain name

This used to return 3000 when running locally on localhost:3000
This commit is contained in:
Ivan Habunek 2023-11-30 11:25:01 +01:00
parent 5d9ee44cec
commit 16e28d02c6
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
1 changed files with 4 additions and 9 deletions

View File

@ -50,16 +50,11 @@ def get_instance_domain(base_url):
# Pleroma and its forks return an actual URI here, rather than a
# domain name like Mastodon. This is contrary to the spec.¯
# in that case, parse out the domain and return it.
uri = instance["uri"]
if uri.startswith("http"):
return urlparse(uri).netloc
parsed_uri = urlparse(instance["uri"])
if parsed_uri.netloc:
# Pleroma, Akkoma, GotoSocial, etc.
return parsed_uri.netloc
else:
# Others including Mastodon servers
return parsed_uri.path
return uri
# NB: when updating to v2 instance endpoint, this field has been renamed to `domain`