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

Fix issue #40: bug in blank query detection.

Was ignoring non-ASCII characters. Thanks to github.com/supergivi for
reporting the bug.
parent 11a08664
No related branches found
No related tags found
No related merge requests found
......@@ -131,7 +131,7 @@ module Geocoder
# Is the given search query blank? (ie, should we not bother searching?)
#
def blank_query?(value)
!value.to_s.match(/[A-z0-9]/)
!!value.to_s.match(/^\s*$/)
end
end
......
# encoding: utf-8
require 'test_helper'
class GeocoderTest < Test::Unit::TestCase
......@@ -213,8 +214,9 @@ class GeocoderTest < Test::Unit::TestCase
def test_blank_query_detection
assert Geocoder.send(:blank_query?, nil)
assert Geocoder.send(:blank_query?, "")
assert Geocoder.send(:blank_query?, ", , (-)")
assert Geocoder.send(:blank_query?, "\t ")
assert !Geocoder.send(:blank_query?, "a")
assert !Geocoder.send(:blank_query?, "Москва") # no ASCII characters
end
def test_does_not_choke_on_nil_address
......
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