Skip to content

Instantly share code, notes, and snippets.

@micc83
Created October 28, 2014 20:05
Show Gist options
  • Save micc83/612c2312be90e4b910cc to your computer and use it in GitHub Desktop.
Save micc83/612c2312be90e4b910cc to your computer and use it in GitHub Desktop.
Add query args to url
/**
* Add query args
*/
function add_query_args(uri, params) {
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
for (var key in params) {
if(params.hasOwnProperty(key)){
uri += separator + key + '=' + params[key];
separator = '&';
}
}
return uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment