Created
October 8, 2009 07:34
-
-
Save dominiek/204845 to your computer and use it in GitHub Desktop.
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 characters
// 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