Created
October 28, 2014 20:05
-
-
Save micc83/612c2312be90e4b910cc to your computer and use it in GitHub Desktop.
Add query args to url
This file contains 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 characters
/** | |
* 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