feat: paginate watching pages + music updates

This commit is contained in:
Cory Dransfeldt 2024-05-26 15:18:17 -07:00
parent 9c0f47278c
commit 0d926fd844
No known key found for this signature in database
25 changed files with 141 additions and 90 deletions

View file

@ -19,4 +19,21 @@ export const sanitizeMediaString = (str) => {
remove: /[#,&,+()$~%.'":*?<>{}]/g,
lower: true,
})
}
export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
export 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(', ')
}