Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upcase body before searching to find lowercase tracking numbers #85

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/tracking_number/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion test/tracking_number_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading