Skip to content

Commit

Permalink
fix some fedex numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
ljmerza committed Jan 8, 2020
1 parent 162985c commit c9eb006
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 43 deletions.
4 changes: 2 additions & 2 deletions dist/tracking-number-card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/tracking-number-card.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Tracking Number Card",
"render_readme": true
}
38 changes: 0 additions & 38 deletions info.md

This file was deleted.

7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,18 @@ class TrackingNumberCard extends LitElement {
let origin = '';
const number = trackerNumber.number;

const isNumber = !isNaN(number);
const length = isNumber && number.toString().length;

if (/^1Z/.test(number)) {
link = `https://www.ups.com/track?loc=en_US&tracknum=${number}`;
origin = 'UPS';

} else if (!isNaN(number) && (number.toString().length === 12 || number.toString().length === 15)){
} else if (isNumber && (length === 12 || length === 15 || length === 20)){
link = `https://www.fedex.com/apps/fedextrack/?tracknumbers=${number}`;
origin = 'FedEx';

} else if (!isNaN(number) && number.toString().length === 22) {
} else if (isNumber && length === 22) {
link = `https://tools.usps.com/go/TrackConfirmAction?tLabels=${number}`;
origin = 'USPS';

Expand Down

0 comments on commit c9eb006

Please sign in to comment.