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

Valid DHL eCommerce tracking numbers fail validation #83

Open
dan-jensen opened this issue Jul 4, 2024 · 3 comments · May be fixed by jkeen/tracking_number_data#104
Open

Valid DHL eCommerce tracking numbers fail validation #83

dan-jensen opened this issue Jul 4, 2024 · 3 comments · May be fixed by jkeen/tracking_number_data#104

Comments

@dan-jensen
Copy link
Contributor

dan-jensen commented Jul 4, 2024

Problem

This gem seems to support DHL eCommerce, but DHL eCommerce tracking numbers fail validation.

It seems the problem is this gem expects DHL eCommerce tracking numbers to start with a 2-letter prefix like "GM", but in my experience they are all-numeric (14 digits).

These are real DHL eCommerce tracking numbers generated between May and July, 2024:

dhl_ecommerce_tracking_numbers = %w[51087693037816 60120172242323 60120174971147]
dhl_ecommerce_tracking_numbers.map do |tracking_code|
  t = TrackingNumber.new(tracking_code)
  t.valid?
end
=> [false, false, false]

Proposal

DHL eCommerce tracking numbers should pass validation.

Additional info

  • DHL has many different pages for checking shipment status. For some reason, most of these pages don't recognize DHL eCommerce tracking numbers and none recognize them when they're freshly-generated. It seems eCommerce tracking numbers are not recognized until they're scanned. I've found this endpoint seems to be the most useful: https://www.dhl.com/us-en/home/tracking/tracking-parcel.html
  • I have not been able to find any information about DHL tracking code format, checksum, etc.
@dan-jensen
Copy link
Contributor Author

@jkeen this is an awesome gem, I've been using it for years. Thanks for maintaining it!

If you can point me in the right direction, I'd be happy to submit a PR.

@jkeen
Copy link
Owner

jkeen commented Aug 19, 2024

@dan-jensen

https://parcelsapp.com/en/carriers/dhl-ecommerce this is where I got that info from.

If you're finding e-commerce numbers that don't fit that, then sounds like there are other cases that haven't been handled. Add your tracking numbers to that "valid" block in the data you pointed to, and then modify the regex to make that that first character group optional (probably just a ? after the inner parentheses would do it) and see if all the tests pass.

@dan-jensen
Copy link
Contributor Author

Tentative PR here: jkeen/tracking_number_data#104

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants