diff --git a/lib/geocoder/query.rb b/lib/geocoder/query.rb index 3da86ef17430b0227dcc9a8cf285a97835197551..ed438610daf36efda133f016238659cbb5b626a8 100644 --- a/lib/geocoder/query.rb +++ b/lib/geocoder/query.rb @@ -37,10 +37,14 @@ module Geocoder end ## - # Is the Query text blank? (ie, should we not bother searching?) + # Is the Query blank? (ie, should we not bother searching?) + # A query is considered blank if its text is nil or empty string AND + # no URL parameters are specified. # def blank? - !!text.to_s.match(/^\s*$/) + !!text.to_s.match(/^\s*$/) and ( + !options[:params].is_a?(Hash) or options[:params].keys.size == 0 + ) end ## diff --git a/test/query_test.rb b/test/query_test.rb index 22a90b5c674d181f7815b19e6949c4ea87d66c80..ee22e4a994c204f4dc3f6517ff83262fae967b45 100644 --- a/test/query_test.rb +++ b/test/query_test.rb @@ -18,6 +18,9 @@ class QueryTest < Test::Unit::TestCase assert Geocoder::Query.new("\t ").blank? assert !Geocoder::Query.new("a").blank? assert !Geocoder::Query.new("МоÑква").blank? # no ASCII characters + + assert Geocoder::Query.new(nil, :params => {}).blank? + assert !Geocoder::Query.new(nil, :params => {:woeid => 1234567}).blank? end def test_coordinates_detection