chore: normalize formatting for workers
This commit is contained in:
parent
2f6cfbe7ae
commit
2cd835d31b
14 changed files with 879 additions and 604 deletions
|
@ -1,10 +1,14 @@
|
|||
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
|
||||
const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()
|
||||
const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
||||
const getCountryName = (countryCode) =>
|
||||
regionNames.of(countryCode.trim()) || countryCode.trim();
|
||||
|
||||
export const parseCountryField = (countryField) => {
|
||||
if (!countryField) return null
|
||||
const delimiters = [',', '/', '&', 'and']
|
||||
let countries = [countryField]
|
||||
delimiters.forEach(delimiter => countries = countries.flatMap(country => country.split(delimiter)))
|
||||
return countries.map(getCountryName).join(', ')
|
||||
}
|
||||
if (!countryField) return null;
|
||||
const delimiters = [",", "/", "&", "and"];
|
||||
let countries = [countryField];
|
||||
delimiters.forEach(
|
||||
(delimiter) =>
|
||||
(countries = countries.flatMap((country) => country.split(delimiter)))
|
||||
);
|
||||
return countries.map(getCountryName).join(", ");
|
||||
};
|
||||
|
|
Reference in a new issue