Skip to content
Snippets Groups Projects
Commit 85f0f9f8 authored by Jed Schneider's avatar Jed Schneider
Browse files

reverting to CGI and letting base class do the work

parent d5a52030
No related branches found
No related tags found
No related merge requests found
require 'uri'
require 'cgi'
require 'geocoder/lookups/base'
require "geocoder/results/mapquest"
......@@ -22,7 +22,7 @@ module Geocoder::Lookup
key = Geocoder::Configuration.api_key
params = { :location => query.sanitized_text }
if key
params[:key] = URI.unescape(key)
params[:key] = CGI.unescape(key)
end
super.merge(params)
end
......@@ -32,11 +32,5 @@ module Geocoder::Lookup
doc["results"][0]['locations']
end
def hash_to_query(hash)
require 'uri' unless defined?(URI) && defined?(URI.escape)
hash.collect{ |p|
p[1].nil? ? nil : p.map{ |i| URI.escape i.to_s } * '='
}.compact.sort * '&'
end
end
end
......@@ -9,11 +9,7 @@ class ServicesTest < Test::Unit::TestCase
next if l == :google_premier # TODO: need to set keys to test
next if l == :freegeoip # does not use query string
# mapquest seems to like URI instead of CGI escaping
regex = if l == :mapquest
/one_in_the_hand=two%20in%20the%20bush/
else
/one_in_the_hand=two\+in\+the\+bush/
end
regex = /one_in_the_hand=two\+in\+the\+bush/
url = Geocoder::Lookup.get(l).send(:query_url, Geocoder::Query.new(
"test", :params => {:one_in_the_hand => "two in the bush"}
))
......@@ -181,7 +177,7 @@ class ServicesTest < Test::Unit::TestCase
lookup = Geocoder::Lookup::Mapquest.new
query = Geocoder::Query.new("Bluffton, SC")
res = lookup.send(:query_url, query)
assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton,%20SC",
assert_equal "http://www.mapquestapi.com/geocoding/v1/address?key=abc123&location=Bluffton%2C+SC",
res
end
......
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