diff --git a/lib/tracking_number/base.rb b/lib/tracking_number/base.rb index 4a905b3..f1eaa09 100644 --- a/lib/tracking_number/base.rb +++ b/lib/tracking_number/base.rb @@ -24,7 +24,7 @@ def self.scan(body) # matches with match groups within the match data matches = [] - body.scan(const_get(:SEARCH_PATTERN)) do + body.upcase.scan(const_get(:SEARCH_PATTERN)) do # get the match data instead, which is needed with these types of regexes matches << $~ end diff --git a/test/tracking_number_test.rb b/test/tracking_number_test.rb index 3baccad..55e2d1e 100644 --- a/test/tracking_number_test.rb +++ b/test/tracking_number_test.rb @@ -40,6 +40,12 @@ class TrackingNumberTest < Minitest::Test assert_equal 1, s.size assert_equal "1Z879E930346834440", s.first.tracking_number end + + should "return tracking numbers entered as lowercase" do + s = TrackingNumber.search("hello 1z879E930346834440 bye") + assert_equal 1, s.size + assert_equal "1Z879E930346834440", s.first.tracking_number + end end context "tracking number additional data for ups" do @@ -201,7 +207,7 @@ class TrackingNumberTest < Minitest::Test context "searching numbers that have partners" do partnership_number = "420 11213 92 6129098349792366623 8" single_number = "92001903060085300042901077" - + search_string = ["number that matches two services", partnership_number, " number that matches only one: ", single_number, "let's see if that does it"].join(' ') should "match only carriers by default" do