Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Created May 14, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terinjokes/991cb27fd3d39da09e4f to your computer and use it in GitHub Desktop.
Save terinjokes/991cb27fd3d39da09e4f to your computer and use it in GitHub Desktop.
function encodeData(data) {
var result = [];
forEach(data, function(value, key) {
if (isArray(value)) {
forEach(value, function(url) {
result.push(encodeURIComponent(key) + '[]=' + encodeURIComponent(url));
});
} else {
result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
}
});
return result.join('&').replace(/%20/g, '+');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment