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

Enhance blank search query checking.

parent 29af848a
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ module Geocoder
# Search for information about an address or a set of coordinates.
#
def search(*args)
return [] if args[0].nil? || args[0] == ""
return [] if blank_query?(args[0])
ip = (args.size == 1 and ip_address?(args.first))
lookup(ip).search(*args)
end
......@@ -81,6 +81,13 @@ module Geocoder
def ip_address?(value)
value.match /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
end
##
# Is the given search query blank? (ie, should we not bother searching?)
#
def blank_query?(value)
!value.to_s.match(/[A-z0-9]/)
end
end
Geocoder::Railtie.insert
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