changeset 2242:e5e54ff0b775

core (tools/common/uri): don't display finale "?" if no extra data is specified
author Goffi <goffi@goffi.org>
date Fri, 19 May 2017 12:40:03 +0200
parents f87b673c7d17
children 5e12fc5ae52a
files src/tools/common/uri.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/common/uri.py	Fri May 19 12:37:54 2017 +0200
+++ b/src/tools/common/uri.py	Fri May 19 12:40:03 2017 +0200
@@ -77,18 +77,19 @@
     for k,v in pairs.iteritems():
         uri.append(u';' + urllib.quote_plus(k) + u'=' + urllib.quote_plus(v))
 
-def buildXMPPUri(type, **kwargs):
+def buildXMPPUri(type_, **kwargs):
     uri = [u'xmpp:']
     subtype = kwargs.pop('subtype', None)
     path = kwargs.pop('path')
     uri.append(urllib.quote_plus(path).replace(u'%40', '@'))
 
-    if type == u'pubsub':
+    if type_ == u'pubsub':
         if subtype == 'microblog' and not 'node' in kwargs:
             kwargs[u'node'] = 'urn:xmpp:microblog:0'
-        uri.append(u'?')
-        addPairs(uri, kwargs)
+        if kwargs:
+            uri.append(u'?')
+            addPairs(uri, kwargs)
     else:
-        raise NotImplementedError(u'{type} URI are not handled yet'.format(type=type))
+        raise NotImplementedError(u'{type_} URI are not handled yet'.format(type_=type_))
 
     return u''.join(uri)