Ensure that search box is resilient to invalid country codes
This commit is contained in:
parent
d5925ac9d5
commit
f8f0f805b4
1 changed files with 8 additions and 2 deletions
|
@ -119,8 +119,14 @@ export const getSearchResults = createSelector(
|
|||
});
|
||||
|
||||
const isIOS = userAgent === 'OWI';
|
||||
const parsedNumber = instance.parse(state.query, regionCode);
|
||||
const isValidNumber = instance.isValidNumber(parsedNumber);
|
||||
let isValidNumber = false;
|
||||
try {
|
||||
// Sometimes parse() throws, like for invalid country codes
|
||||
const parsedNumber = instance.parse(state.query, regionCode);
|
||||
isValidNumber = instance.isValidNumber(parsedNumber);
|
||||
} catch (_) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
if (!isIOS && isValidNumber) {
|
||||
items.push({
|
||||
|
|
Loading…
Reference in a new issue