22 lines
No EOL
576 B
JavaScript
22 lines
No EOL
576 B
JavaScript
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));
|
|
let temp = array[i];
|
|
array[i] = array[j];
|
|
array[j] = temp;
|
|
}
|
|
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,
|
|
})
|
|
} |