Created
May 19, 2011 05:07
-
-
Save kilork/980229 to your computer and use it in GitHub Desktop.
Revisions
-
kilork created this gist
May 19, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ function toUriParameter(obj, post) { var key, value, parts = [], encode = post ? function(s) { return window.encodeURIComponent(s).replace(/%20/g,'+'); } : window.encodeURIComponent, iterator = function(item) { parts.push(encode(key) + '=' + encode(item)); }; for (key in obj) { if (obj.hasOwnProperty(key)) { value = obj[key]; if (value instanceof Array) { value.forEach(iterator); } else { parts.push(encode(key) + '=' + encode(value)); } } } return parts.join('&'); }