chore: worker cleanup
This commit is contained in:
parent
8b2648f23f
commit
3aadaeb741
10 changed files with 464 additions and 425 deletions
10
workers/dynamic-pages/utils/countries.js
Normal file
10
workers/dynamic-pages/utils/countries.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
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(', ')
|
||||
}
|
Reference in a new issue