diff --git a/slixmpp/plugins/xep_0454/__init__.py b/slixmpp/plugins/xep_0454/__init__.py index 09d41221..34db0c79 100644 --- a/slixmpp/plugins/xep_0454/__init__.py +++ b/slixmpp/plugins/xep_0454/__init__.py @@ -117,7 +117,7 @@ class XEP_0454(BasePlugin): """Helper to format a HTTPS URL to an AESGCM URI""" if not url.startswith('https://') or url.find('#') != -1: raise InvalidURL - url = 'aesgcm://' + url.removeprefix('https://') + '#' + fragment + return 'aesgcm://' + url.removeprefix('https://') + '#' + fragment async def upload_file( self, diff --git a/tests/test_xep_0454.py b/tests/test_xep_0454.py index 3d0860a9..8d43c7e3 100644 --- a/tests/test_xep_0454.py +++ b/tests/test_xep_0454.py @@ -32,4 +32,10 @@ class TestMediaSharing(SlixTest): self.assertEqual(plain, result) + def testFormatURL(self): + url = 'https://foo.bar' + fragment = 'a' * 88 + result = XEP_0454.format_url(url, fragment) + self.assertEqual('aesgcm://foo.bar#' + 'a' * 88, result) + suite = unittest.TestLoader().loadTestsFromTestCase(TestMediaSharing)