From 7222ade0dd252380fb158bb9b1ca1fefec3899a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= <pep@bouah.net>
Date: Fri, 18 Mar 2022 16:11:07 +0100
Subject: xep_0454: Ensure format_url returns a str
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
---
 slixmpp/plugins/xep_0454/__init__.py | 2 +-
 tests/test_xep_0454.py               | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

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)
-- 
cgit v1.2.3