ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [2/7] incubator-ponymail git commit: detect if form data is a hash or not
Date Fri, 02 Sep 2016 11:19:39 GMT
detect if form data is a hash or not

if not, just return empty string.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/271f10f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/271f10f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/271f10f1

Branch: refs/heads/coffee-and-cake
Commit: 271f10f1fa3823d6b54f37ef585eb73147ae3559
Parents: 58a1dbd
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Fri Sep 2 12:56:34 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Fri Sep 2 12:56:34 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/http_utils.coffee | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/271f10f1/site/js/coffee/http_utils.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/http_utils.coffee b/site/js/coffee/http_utils.coffee
index 60d8e13..3194a25 100644
--- a/site/js/coffee/http_utils.coffee
+++ b/site/js/coffee/http_utils.coffee
@@ -76,7 +76,7 @@ class HTTPRequest
                 @rdata = @formdata(@data)
                 
         ### If tasked with appending data to the URL, do so ###
-        if @getdata
+        if isHash(@getdata)
             tmp = @formdata(@getdata)
             if tmp.length > 0
                 ### Do we have form data here aleady? if so, append the new ###
@@ -125,11 +125,12 @@ class HTTPRequest
     ### Standard form data joiner for POST data ###
     formdata: (kv) ->
         ar = []
-        ### For each key/value pair ###
-        for k,v of kv
-            ### Only append if the value is non-empty ###
-            if v and v != ""
-                ###  URI-Encode value and add to an array ###
-                ar.push(k + "=" + encodeURIComponent(v))
+        ### For each key/value pair (assuming this is a hash) ###
+        if isHash(kv)
+            for k,v of kv
+                ### Only append if the value is non-empty ###
+                if v and v != ""
+                    ###  URI-Encode value and add to an array ###
+                    ar.push(k + "=" + encodeURIComponent(v))
         ### Join the array with ampersands, so we get "foo=bar&foo2=baz" ###
         return ar.join("&")


Mime
View raw message