lib/geocoder/lookups/bing.rb in geocoder-1.4.9 vs lib/geocoder/lookups/bing.rb in geocoder-1.5.0
- old
+ new
@@ -14,27 +14,23 @@
def required_api_key_parts
["key"]
end
- def query_url(query)
- base_url(query) + url_query_string(query)
- end
-
private # ---------------------------------------------------------------
- def base_url(query)
- url = "#{protocol}://dev.virtualearth.net/REST/v1/Locations"
-
- if !query.reverse_geocode?
+ def base_query_url(query)
+ text = CGI.escape(query.sanitized_text.strip)
+ url = "#{protocol}://dev.virtualearth.net/REST/v1/Locations/"
+ if query.reverse_geocode?
+ url + "#{text}?"
+ else
if r = query.options[:region]
- url << "/#{r}"
+ url << "#{r}/"
end
# use the more forgiving 'unstructured' query format to allow special
# chars, newlines, brackets, typos.
- url + "?q=" + URI.escape(query.sanitized_text.strip) + "&"
- else
- url + "/#{URI.escape(query.sanitized_text.strip)}?"
+ url + "?q=#{text}&"
end
end
def results(query)
return [] unless doc = fetch_data(query)