diff --git a/common.py b/common.py index a5967ba..51fbee3 100644 --- a/common.py +++ b/common.py @@ -351,6 +351,8 @@ def redirect_wrap(url): https://github.com/snarfed/bridgy-fed/issues/16#issuecomment-424799599 https://github.com/tootsuite/mastodon/pull/6219#issuecomment-429142747 """ + if not url: + return url if url.startswith(REDIRECT_PREFIX): return url return REDIRECT_PREFIX + url diff --git a/tests/test_common.py b/tests/test_common.py index 2839e73..bfa5c10 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -64,3 +64,7 @@ class CommonTest(testutil.TestCase): with self.assertRaises(exc.HTTPBadGateway): resp = common.get_as2('http://orig') + def test_redirect_wrap_empty(self): + self.assertIsNone(common.redirect_wrap(None)) + self.assertEqual('', common.redirect_wrap('')) +