Skip to content

Instantly share code, notes, and snippets.

@ranaroussi
Created October 31, 2012 08:18
Show Gist options
  • Save ranaroussi/3985821 to your computer and use it in GitHub Desktop.
Save ranaroussi/3985821 to your computer and use it in GitHub Desktop.
prepare string for use in urls
function querify(str) {
str = encodeURIComponent(str.replace(/,/gi, ' ').replace(/\s{2,}/gi, ' ')).replace(/%20/gi, '+');
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment