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

Add DHL eCommerce 14-digit format #104

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions couriers/dhl.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@
{
"name": "DHL E-Commerce",
"id": "dhl_ecommerce",
"regex": "\\s*((GM)|(LX)|(RX)|(UV)|(CN)|(SG)|(TH)|(IN)|(HK)|(MY))\\s*(?<SerialNumber>([0-9]\\s*){10,39})",
"regex": [
"(\\s*((GM)|(LX)|(RX)|(UV)|(CN)|(SG)|(TH)|(IN)|(HK)|(MY))\\s*(?<SerialNumber>([0-9]\\s*){10,39}))",
"|^(?<SerialNumber>([0-9]){14})$"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkeen this pattern matches USPS 20-digit numbers (and possibly other formats), and apparently there is no validation mechanism (mod7/luhn/etc). So it seems we need to be clever.

As you see here, I tried wrapping it in line start/end syntax (^/$). However, this makes it un-usable for search blocks of text, and it fails the should_detect_number_variants test. Seems like the line start/end synax must be removed. Any ideas on how to modify this pattern so it does NOT match USPS 20-digits?

],
"validation": {},
"tracking_url": "http://www.dhl.com/en/express/tracking.html?brand=DHL&AWB=%s",
"test_numbers": {
"valid": [
"GM2951173225174494",
"GM 2 9 5 117 32 25 1 7 44 9 4",
"GM295117494011169042"
"GM295117494011169042",
"51087693037816",
"60120172242323",
"60120174971147"
],
"invalid": [
"GS295117494011169041",
Expand Down
Loading