chore: refactoring
This commit is contained in:
parent
df5fddefc0
commit
e0593447eb
40 changed files with 181 additions and 232 deletions
|
@ -1,5 +1,3 @@
|
|||
import slugify from 'slugify'
|
||||
|
||||
export const shuffleArray = array => {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1))
|
||||
|
@ -10,17 +8,6 @@ export const shuffleArray = array => {
|
|||
return array
|
||||
}
|
||||
|
||||
export const sanitizeMediaString = (str) => {
|
||||
if (!str) return null
|
||||
const sanitizedString = str.normalize('NFD').replace(/[\u0300-\u036f\u2010—\.\?\(\)\[\]\{\}]/g, '').replace(/\.{3}/g, '')
|
||||
|
||||
return slugify(sanitizedString, {
|
||||
replacement: '-',
|
||||
remove: /[#,&,+()$~%.'":*?<>{}]/g,
|
||||
lower: true,
|
||||
})
|
||||
}
|
||||
|
||||
export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
|
||||
|
||||
export const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()
|
||||
|
|
Reference in a new issue