Skip to content

Instantly share code, notes, and snippets.

@dominiek
Created October 8, 2009 07:34
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 dominiek/204845 to your computer and use it in GitHub Desktop.
Save dominiek/204845 to your computer and use it in GitHub Desktop.
// Generate URL: e.g. $.url('http://smart.fm/goals?first=1', {'second': 2});
// By Andrew Plummer
$.url = function(base, params, options){
var url = base;
var options = options || {};
if(params){
if(!url.match(/\?$/)) {
if(url.match(/\?/)) {
url += '&';
} else {
url += '?';
}
}
url += $.param(params, options);
}
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment