From 7ae708c55b2a1d2a23d90cfc9224d5cb2c57f719 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 14 Jan 2023 23:52:01 -0700 Subject: [PATCH] Add carrier barcode regex for USPS DataMatrix --- lib/Carriers.lib.php | 2 +- lib/TrackingBarcode.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Carriers.lib.php b/lib/Carriers.lib.php index 47ef134..f91fc6d 100644 --- a/lib/Carriers.lib.php +++ b/lib/Carriers.lib.php @@ -49,7 +49,7 @@ class Carriers { ], [ "carrier" => "usps", - "pattern" => "/^\\x1D420[0-9]{5,11}\\x1D[0-9]{10,}\\x1D?$/" + "pattern" => "/^\\x1D?420[0-9]{5,11}\\x1D?[0-9]{10,}\\x1D?$/" ], [ "carrier" => "usps", diff --git a/lib/TrackingBarcode.lib.php b/lib/TrackingBarcode.lib.php index 044f48b..c9050f7 100644 --- a/lib/TrackingBarcode.lib.php +++ b/lib/TrackingBarcode.lib.php @@ -30,7 +30,7 @@ class TrackingBarcode { public function getCarrier(): string { $carrier = ""; foreach (Carriers::CARRIER_REGEXES as $p) { - if (preg_match($p["pattern"], strtoupper($this->code))) { + if (preg_match($p["pattern"]."i", $this->code)) { $carrier = $p["carrier"]; break; }