]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Don't add an extra delimter when no arguments are given
authorBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 01:24:07 +0000 (18:24 -0700)
committerBen Darnell <ben@bendarnell.com>
Sun, 29 May 2011 01:24:07 +0000 (18:24 -0700)
tornado/httputil.py
tornado/test/httputil_test.py

index b33ea33e9afd5ee9dc5f8af6801c92e35dcc9970..04a21fbc0276a6700b4cba5afd38b576d7cbf8e0 100644 (file)
@@ -156,6 +156,7 @@ def url_concat(url, args):
     >>> url_concat("http://example.com/foo?a=b", dict(c="d"))
     'http://example.com/foo?a=b&c=d'
     """
+    if not args: return url
     if url[-1] not in ('?', '&'):
         url += '&' if ('?' in url) else '?'
     return url + urllib.urlencode(args)
index abad065e059e149a51c5752ca4de3ea03a899443..d73295958a5618d72a891df1e4ace60e4f82cf17 100644 (file)
@@ -47,3 +47,10 @@ class TestUrlConcat(unittest.TestCase):
                 {'y':'y', 'z':'z'},
                 )
         self.assertEqual(url, "https://localhost/path?a=1&b=2&y=y&z=z")
+
+    def test_url_concat_no_params(self):
+        url = url_concat(
+            "https://localhost/path?r=1&t=2",
+            {},
+            )
+        self.assertEqual(url, "https://localhost/path?r=1&t=2")