diff --git a/mastodon/internals.py b/mastodon/internals.py index 5269880..29c4e4a 100644 --- a/mastodon/internals.py +++ b/mastodon/internals.py @@ -616,7 +616,10 @@ def __normalize_version_string(self, version_string): version_string = version_string.split(" ")[0] try: # Attempt to split at + and check if the part after parses as a version string, to account for hometown - parse_version_string(version_string.split("+")[1]) + ver_parts = parse_version_string(version_string.split("+")[1]) + # If the parsed version is less than 1.0, assume it's GoToSocial and return the *first* part + if ver_parts[0] < 1: + return version_string.split("+")[0] return version_string.split("+")[1] except: # If this fails, assume that if there is a +, what is before that is the masto version (or that there is no +) diff --git a/tests/test_instance.py b/tests/test_instance.py index ff86191..309e742 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -95,3 +95,4 @@ def test_version_parsing(api): assert parse_version_string(api._Mastodon__normalize_version_string("3.5.1+chitter6.6.6")) == (3, 5, 1) assert parse_version_string(api._Mastodon__normalize_version_string("3.5.0 (compatible; Pleroma 1.2.3)")) == (3, 5, 0) assert parse_version_string(api._Mastodon__normalize_version_string("3.2.1rc3 (compatible; Akkoma 3.2.4+shinychariot)")) == (3, 2, 1) + assert parse_version_string(api._Mastodon__normalize_version_string("3.5.3+0.17.3+git-6f4cb2f")) == (3, 5, 3)