Allow None in parurl values to omit keys.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 21 Mar 2018 16:15:16 +0000 (17:15 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 21 Mar 2018 16:15:16 +0000 (17:15 +0100)
wrw/proto.py

index 80e2419..70f8f77 100644 (file)
@@ -187,11 +187,15 @@ def parstring(pars={}, **augment):
             del augment[key]
         else:
             val = pars[key]
             del augment[key]
         else:
             val = pars[key]
+        if val is None:
+            continue
         if buf != "": buf += "&"
         buf += urlq(key) + "=" + urlq(str(val))
         if buf != "": buf += "&"
         buf += urlq(key) + "=" + urlq(str(val))
-    for key in augment:
+    for key, val in augment.items():
+        if val is None:
+            continue
         if buf != "": buf += "&"
         if buf != "": buf += "&"
-        buf += urlq(key) + "=" + urlq(str(augment[key]))
+        buf += urlq(key) + "=" + urlq(str(val))
     return buf
 
 def parurl(url, pars={}, **augment):
     return buf
 
 def parurl(url, pars={}, **augment):