Ensure that search box is resilient to invalid country codes

This commit is contained in:
Scott Nonnenberg 2020-04-23 12:26:20 -07:00
parent d5925ac9d5
commit f8f0f805b4

View file

@ -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({