Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 26 additions & 0 deletions couriers/canpar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Canpar",
"courier_code": "canpar",
"tracking_numbers": [
{
"name": "Canpar (22)",
"id": "canpar_22",
"regex": "\\s*(?<SerialNumber>[CDKLSUXZ]\\s*([0-9]\\s*){21})\\s*",
"validation": {},
"tracking_url": "https://www.canpar.com/en/track/tracking.jsp?reference=%s&locale=en",
"test_numbers": {
"valid": [
"D576002440000002510003",
"D576002440000002510001",
"D576002440000002508002",
"D576002440000002507003"
],
"invalid": [
"1576002440000002510003",
"D57600244000000251000",
"M576002440000002510003"
]
}
}
]
}
50 changes: 50 additions & 0 deletions couriers/purolator.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "Purolator",
"courier_code": "purolator",
"tracking_numbers": [
{
"name": "Purolator (12)",
"id": "purolator_numeric",
"regex": "\\s*(?<SerialNumber>[0-5]\\s*([0-9]\\s*){10})(?<CheckDigit>[0-9]\\s*)",
"validation": {
"checksum": {
"name": "luhn"
}
},
"tracking_url": "https://www.purolator.com/en/shipping/tracker?searchValue=%s",
"test_numbers": {
"valid": [
"320595463938",
"320606146993",
"287809468872",
"320610804900",
"331426749957",
"331434972567"
],
"invalid": [
"320595463939",
"287809468875"
]
}
},
{
"name": "Purolator (alpha + 9)",
"id": "purolator_alpha",
"regex": "\\s*(?<SerialNumber>([A-Z]\\s*){3}([0-9]\\s*){9})\\s*",
"validation": {},
"tracking_url": "https://www.purolator.com/en/shipping/tracker?searchValue=%s",
"test_numbers": {
"valid": [
"KYV009956937",
"CGK002986959",
"JFV247545960",
"TLR000083964"
],
"invalid": [
"KY009956937",
"331426749957"
]
Comment on lines +33 to +46
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

[A-Z]{3}[0-9]{9} is a very broad pattern — high false-positive risk.

Any string of 3 uppercase letters followed by 9 digits will match. There are no carrier-specific prefix constraints to narrow this down. With no checksum to act as a secondary gate, this definition could spuriously match tracking numbers from other carriers that also use alphanumeric prefixes.

Consider whether known Purolator three-letter prefixes can be enumerated (e.g., (?:KYV|CGK|JFV|TLR|...)) to reduce the collision surface, or at minimum note in a comment why the open-ended character class is necessary.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@couriers/purolator.json` around lines 33 - 46, The regex field currently uses
a broad pattern "\\s*(?<SerialNumber>([A-Z]\\s*){3}([0-9]\\s*){9})\\s*" which
will match any 3 uppercase letters + 9 digits and cause false positives; tighten
it by replacing the ([A-Z]{3}) portion with an alternation of known Purolator
prefixes (e.g., (?:KYV|CGK|JFV|TLR|...)) or otherwise restrict the allowed
prefix set, or if that’s not possible add a clear comment in the JSON explaining
why a broad class is required and add a secondary validation rule in the
"validation" object (e.g., prefix whitelist or checksum logic) to reduce
collisions so consumers use both the refined regex and the "validation" checks
to accept numbers.

}
}
]
}
26 changes: 26 additions & 0 deletions couriers/speedee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Spee-Dee Delivery",
"courier_code": "speedee",
"tracking_numbers": [
{
"name": "Spee-Dee (20)",
"id": "speedee",
"regex": "\\s*S\\s*P\\s*(?<SerialNumber>([0-9]\\s*){18})\\s*",
"validation": {},
"tracking_url": "https://www.speedeedelivery.com/track/?tracking=%s",
"test_numbers": {
"valid": [
"SP029692510000920746",
"SP029692510000901479",
"SP029692510000688332",
"SP029692510000279301",
"SP029692450001607639"
],
"invalid": [
"029692510000920746",
"SX029692510000920746"
]
}
}
]
}