@aircall/numbers
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.2.4](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/numbers@0.2.3...@aircall/numbers@0.2.4) (2020-04-06) | ||
**Note:** Version bump only for package @aircall/numbers | ||
## [0.2.3](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/numbers@0.2.2...@aircall/numbers@0.2.3) (2020-04-02) | ||
@@ -8,0 +16,0 @@ |
@@ -46,3 +46,3 @@ "use strict"; | ||
// We assume that in this case the number does not have a `+` sign | ||
if (error.message === 'INVALID_COUNTRY') { | ||
if (error.message === 'INVALID_COUNTRY' && !phoneNumber.startsWith('+')) { | ||
const numberWithPlusSign = normalizeNumber(phoneNumber); | ||
@@ -49,0 +49,0 @@ return formatInternational(numberWithPlusSign); |
@@ -47,3 +47,12 @@ import { PhoneNumber as LibPhonenumberPhoneNumber } from 'libphonenumber-js/max'; | ||
* possible validity in detected, default or currently selected country. | ||
* | ||
* @param phoneNumber - Phone number to parse | ||
* @param countryCode - Country code to parse the number with | ||
* @param defaultCountryCode - Default country code as a potential fallback | ||
* if number is invalid in current country code | ||
* @param isTyping - Whether the number is being types (as opposed to pasting). | ||
* We handle those cases differently | ||
* | ||
* @returns - Country code | ||
*/ | ||
export declare const guessCountryCode: (phoneNumber: string, countryCode: import("libphonenumber-js/types").CountryCode, defaultCountryCode: import("libphonenumber-js/types").CountryCode, isTyping: boolean) => import("libphonenumber-js/types").CountryCode; | ||
export declare function guessCountryCode(phoneNumber: string, countryCode: CountryCode, defaultCountryCode: CountryCode, isTyping: boolean): CountryCode; |
@@ -90,4 +90,13 @@ "use strict"; | ||
* possible validity in detected, default or currently selected country. | ||
* | ||
* @param phoneNumber - Phone number to parse | ||
* @param countryCode - Country code to parse the number with | ||
* @param defaultCountryCode - Default country code as a potential fallback | ||
* if number is invalid in current country code | ||
* @param isTyping - Whether the number is being types (as opposed to pasting). | ||
* We handle those cases differently | ||
* | ||
* @returns - Country code | ||
*/ | ||
exports.guessCountryCode = (phoneNumber, countryCode, defaultCountryCode, isTyping) => { | ||
function guessCountryCode(phoneNumber, countryCode, defaultCountryCode, isTyping) { | ||
// If no number return currently selected country | ||
@@ -130,3 +139,4 @@ if (!phoneNumber) { | ||
return countryCode; | ||
}; | ||
} | ||
exports.guessCountryCode = guessCountryCode; | ||
//# sourceMappingURL=parsing.js.map |
{ | ||
"name": "@aircall/numbers", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"main": "dist/index.js", | ||
@@ -14,3 +14,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "b78b28cbf565454ebe6f37580f3f8df9609bc857", | ||
"gitHead": "4d0c82e0a9c84f02df3b66826946e2fc4cbe6bed", | ||
"dependencies": { | ||
@@ -17,0 +17,0 @@ "libphonenumber-js": "1.7.49" |
@@ -48,3 +48,3 @@ import { AsYouType, getCountryCallingCode, parsePhoneNumber } from 'libphonenumber-js/max'; | ||
// We assume that in this case the number does not have a `+` sign | ||
if (error.message === 'INVALID_COUNTRY') { | ||
if (error.message === 'INVALID_COUNTRY' && !phoneNumber.startsWith('+')) { | ||
const numberWithPlusSign = normalizeNumber(phoneNumber); | ||
@@ -51,0 +51,0 @@ |
@@ -113,4 +113,13 @@ import { | ||
* possible validity in detected, default or currently selected country. | ||
* | ||
* @param phoneNumber - Phone number to parse | ||
* @param countryCode - Country code to parse the number with | ||
* @param defaultCountryCode - Default country code as a potential fallback | ||
* if number is invalid in current country code | ||
* @param isTyping - Whether the number is being types (as opposed to pasting). | ||
* We handle those cases differently | ||
* | ||
* @returns - Country code | ||
*/ | ||
export const guessCountryCode = ( | ||
export function guessCountryCode( | ||
phoneNumber: string, | ||
@@ -120,3 +129,3 @@ countryCode: CountryCode, | ||
isTyping: boolean | ||
): CountryCode => { | ||
): CountryCode { | ||
// If no number return currently selected country | ||
@@ -167,2 +176,2 @@ if (!phoneNumber) { | ||
return countryCode; | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
505003
4839