diff --git a/geocoder/mapbox.py b/geocoder/mapbox.py index 90095330..096b3acf 100644 --- a/geocoder/mapbox.py +++ b/geocoder/mapbox.py @@ -6,6 +6,11 @@ from geocoder.keys import mapbox_access_token from geocoder.location import BBox, Location +try: # Python 2 compat + from urllib.parse import quote +except ImportError: + from urllib import quote + class MapboxResult(OneResult): @@ -136,7 +141,7 @@ def _build_params(self, location, provider_key, **kwargs): return base_params def _before_initialize(self, location, **kwargs): - self.url = self.url.format(location) + self.url = self.url.format(quote(location)) def _adapt_results(self, json_response): # extract the array of JSON objects