Skip to content
Snippets Groups Projects
Commit 92f17f87 authored by Alex Reisner's avatar Alex Reisner
Browse files

Merge pull request #675 from nickelser/master

Fix Bing reverse geocode lookups
parents 2708891e b00a01c5
No related branches found
No related tags found
No related merge requests found
......@@ -24,12 +24,17 @@ module Geocoder::Lookup
def base_url(query)
url = "#{protocol}://dev.virtualearth.net/REST/v1/Locations"
if !query.reverse_geocode? and r = query.options[:region]
url << "/#{r}"
if !query.reverse_geocode?
if r = query.options[:region]
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)}?"
end
# use the more forgiving 'unstructured' query format to allow special
# chars, newlines, brackets, typos.
url + "?q=" + URI.escape(query.sanitized_text.strip) + "&"
end
def results(query)
......
......@@ -12,7 +12,7 @@ class BingTest < GeocoderTestCase
def test_query_for_reverse_geocode
lookup = Geocoder::Lookup::Bing.new
url = lookup.query_url(Geocoder::Query.new([45.423733, -75.676333]))
assert_match(/Locations\?q=45.423733/, url)
assert_match(/Locations\/45.423733/, url)
end
def test_result_components
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment