Closed Russ93 closed 9 years ago
Sorry for the late response @Russ93 . Wouldn't it just be better to just incorporate the /^K\d{10}$/1
regex for UPS in shipit
? What's the reasoning behind making the regex array dynamic and user-modifiable? Do you expect people to be using "custom" carriers, where "UPS" means one thing for one app, and means something totally different for another app? I intend for shipit
to work with well recognized carriers, and if there's a format of tracking number that can and should be recognized, that shipit
doesn't recognize, then we should just updated's shipit's in-built regexes.
Also, /^K\d{10}$/
is way too generic, without any checksum or other secondary validation. It is a difficult balance between trying to get all possible carrier matches, and minimizing false-positives. But whenever possible, I think shipit
should only recognize carriers when it is almost certain it is correct. DHL is usually the most difficult one, because it uses 10 or 7 digit tracking numbers, with little or no checksum validation, or mod-digits. That's the reason guessCarrier
currently doesn't return 'dhl'
even though DHL is a recognized and supported carrier.
Another UPS tracking regex /^K\d{10}$/i
it would be nice to be able to add custom objects to the array i.e. {name: 'ups', regex:/^K\d{10}$/i }
I am unsure how you would like to but if the array of carrier regex could be exposed somewhere would be nice
here is one way to do it src/guessCarrier.coffee line 108
I can just go