From 7342234fe0afe0aa9521c608efaec8c040a16d76 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Mon, 23 Mar 2015 11:27:50 -0400 Subject: [PATCH] Force all SmartyStreets requests to use HTTPS. --- README.md | 2 +- lib/geocoder/lookups/smarty_streets.rb | 4 ++++ test/unit/lookups/smarty_streets_test.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44ebdd01..d8545990 100644 --- a/README.md +++ b/README.md @@ -580,7 +580,7 @@ Data Science Toolkit provides an API whose reponse format is like Google's but w * **API key**: requires auth_id and auth_token (set `Geocoder.configure(:api_key => [id, token])`) * **Quota**: 10,000 free, 250/month then purchase at sliding scale. * **Region**: US -* **SSL support**: yes +* **SSL support**: yes (required) * **Languages**: en * **Documentation**: http://smartystreets.com/kb/liveaddress-api/rest-endpoint * **Terms of Service**: http://smartystreets.com/legal/terms-of-service diff --git a/lib/geocoder/lookups/smarty_streets.rb b/lib/geocoder/lookups/smarty_streets.rb index db48738f..2aebf07a 100644 --- a/lib/geocoder/lookups/smarty_streets.rb +++ b/lib/geocoder/lookups/smarty_streets.rb @@ -18,6 +18,10 @@ module Geocoder::Lookup private # --------------------------------------------------------------- + def protocol + "https" # required by API as of 26 March 2015 + end + def zipcode_only?(query) !query.text.is_a?(Array) and query.to_s.strip =~ /\A\d{5}(-\d{4})?\Z/ end diff --git a/test/unit/lookups/smarty_streets_test.rb b/test/unit/lookups/smarty_streets_test.rb index b9c7f0c7..7befd044 100644 --- a/test/unit/lookups/smarty_streets_test.rb +++ b/test/unit/lookups/smarty_streets_test.rb @@ -11,7 +11,7 @@ class SmartyStreetsTest < GeocoderTestCase def test_url_contains_api_key Geocoder.configure(:smarty_streets => {:api_key => 'blah'}) query = Geocoder::Query.new("Bluffton, SC") - assert_equal "http://api.smartystreets.com/street-address?auth-token=blah&street=Bluffton%2C+SC", query.url + assert_equal "https://api.smartystreets.com/street-address?auth-token=blah&street=Bluffton%2C+SC", query.url end def test_query_for_address_geocode -- GitLab