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/lookups/base'
require "geocoder/results/mapquest" require "geocoder/results/mapquest"
...@@ -22,7 +22,7 @@ module Geocoder::Lookup ...@@ -22,7 +22,7 @@ module Geocoder::Lookup
key = Geocoder::Configuration.api_key key = Geocoder::Configuration.api_key
params = { :location => query.sanitized_text } params = { :location => query.sanitized_text }
if key if key
params[:key] = URI.unescape(key) params[:key] = CGI.unescape(key)
end end
super.merge(params) super.merge(params)
end end
...@@ -32,11 +32,5 @@ module Geocoder::Lookup ...@@ -32,11 +32,5 @@ module Geocoder::Lookup
doc["results"][0]['locations'] doc["results"][0]['locations']
end 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
end end
...@@ -9,11 +9,7 @@ class ServicesTest < Test::Unit::TestCase ...@@ -9,11 +9,7 @@ class ServicesTest < Test::Unit::TestCase
next if l == :google_premier # TODO: need to set keys to test next if l == :google_premier # TODO: need to set keys to test
next if l == :freegeoip # does not use query string next if l == :freegeoip # does not use query string
# mapquest seems to like URI instead of CGI escaping # mapquest seems to like URI instead of CGI escaping
regex = if l == :mapquest regex = /one_in_the_hand=two\+in\+the\+bush/
/one_in_the_hand=two%20in%20the%20bush/
else
/one_in_the_hand=two\+in\+the\+bush/
end
url = Geocoder::Lookup.get(l).send(:query_url, Geocoder::Query.new( url = Geocoder::Lookup.get(l).send(:query_url, Geocoder::Query.new(
"test", :params => {:one_in_the_hand => "two in the bush"} "test", :params => {:one_in_the_hand => "two in the bush"}
)) ))
...@@ -181,7 +177,7 @@ class ServicesTest < Test::Unit::TestCase ...@@ -181,7 +177,7 @@ class ServicesTest < Test::Unit::TestCase
lookup = Geocoder::Lookup::Mapquest.new lookup = Geocoder::Lookup::Mapquest.new
query = Geocoder::Query.new("Bluffton, SC") query = Geocoder::Query.new("Bluffton, SC")
res = lookup.send(:query_url, query) 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 res
end 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