Use encodeURIComponent to ensure all special characters in the query are escaped

Previously + was not being escaped causing it to be treated as a space in queries.