Encode string and replace /%20/ with +

Javascript

Encode string and replace /%20/ with + to be used in a URL

javascript

encodeURI(query).replace(/%20/g, '+');