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

Stop using URI.escape.

Fixes #609. Bing seems to support this type of character escaping now.
It's not discussed in their documentation but it works with every query
I've tried so hopefully we're finally good on this issue.

Also remove some unnecessary assertions from tests.
parent 2216dccf
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ module Geocoder::Lookup
private # ---------------------------------------------------------------
def base_url(query)
text = URI.escape(query.sanitized_text.strip)
text = CGI.escape(query.sanitized_text.strip)
url = "#{protocol}://dev.virtualearth.net/REST/v1/Locations/"
if query.reverse_geocode?
url + "#{text}?"
......
......@@ -43,7 +43,6 @@ class BingTest < GeocoderTestCase
:region => "uk"
))
assert_match(%r!Locations/uk/\?q=manchester!, url)
assert_no_match(/query/, url)
end
def test_query_url_without_region
......@@ -52,27 +51,24 @@ class BingTest < GeocoderTestCase
"manchester"
))
assert_match(%r!Locations/\?q=manchester!, url)
assert_no_match(/query/, url)
end
def test_query_url_contains_address_with_spaces
def test_query_url_escapes_spaces_in_address
lookup = Geocoder::Lookup::Bing.new
url = lookup.query_url(Geocoder::Query.new(
"manchester, lancashire",
:region => "uk"
))
assert_match(%r!Locations/uk/\?q=manchester,%20lancashire!, url)
assert_no_match(/query/, url)
assert_match(%r!Locations/uk/\?q=manchester%2C\+lancashire!, url)
end
def test_query_url_contains_address_with_trailing_and_leading_spaces
def test_query_url_strips_trailing_and_leading_spaces
lookup = Geocoder::Lookup::Bing.new
url = lookup.query_url(Geocoder::Query.new(
" manchester, lancashire ",
:region => "uk"
))
assert_match(%r!Locations/uk/\?q=manchester,%20lancashire!, url)
assert_no_match(/query/, url)
assert_match(%r!Locations/uk/\?q=manchester%2C\+lancashire!, url)
end
def test_raises_exception_when_service_unavailable
......
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