Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
feat: sanitize postal code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonyw4 committed Jul 7, 2020
1 parent e178ffd commit 0045966
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MelhorEnvio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class MelhorEnvio {
this.timeout = timeout;
}

private sanitizePostalCode(postalCode: string) {
return postalCode.toString().replace(/\D+/g, '');
}

/**
* 📨 Fetch in the MelhorEnvio API
*
Expand Down Expand Up @@ -101,10 +105,10 @@ class MelhorEnvio {
) {
const data: any = {
from: {
postal_code: fromPostalCode
postal_code: this.sanitizePostalCode(fromPostalCode)
},
to: {
postal_code: toPostalCode
postal_code: this.sanitizePostalCode(toPostalCode)
},
options: {
receipt,
Expand Down

0 comments on commit 0045966

Please sign in to comment.