mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
The uniqueSlug charmap option was set to the multicharmap in order to keep the modified german umlaut settings to overide the internal settings for other diacritics. The test cases strings were extended to improve coverage of diacritic removal.
This commit is contained in:
parent
c8ac972e20
commit
00e0ccd7a4
@ -2,7 +2,7 @@ import slugify from 'slug'
|
||||
export default async function uniqueSlug(string, isUnique) {
|
||||
const slug = slugify(string || 'anonymous', {
|
||||
lower: true,
|
||||
charmap: { Ä: 'AE', ä: 'ae', Ö: 'OE', ö: 'oe', Ü: 'UE', ü: 'ue', ñ: 'n' },
|
||||
multicharmap: { Ä: 'AE', ä: 'ae', Ö: 'OE', ö: 'oe', Ü: 'UE', ü: 'ue', ß: 'ss' },
|
||||
})
|
||||
if (await isUnique(slug)) return slug
|
||||
|
||||
|
||||
@ -20,14 +20,14 @@ describe('uniqueSlug', () => {
|
||||
})
|
||||
|
||||
it('Converts umlaut to a two letter equivalent', async () => {
|
||||
const umlaut = 'ä'
|
||||
const umlaut = 'ÄÖÜäöüß'
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
await expect(uniqueSlug(umlaut, isUnique)).resolves.toEqual('ae')
|
||||
await expect(uniqueSlug(umlaut, isUnique)).resolves.toEqual('aeoeueaeoeuess')
|
||||
})
|
||||
|
||||
it('Removes Spanish enya ', async () => {
|
||||
const enya = 'ñ'
|
||||
it('Removes Spanish enya and diacritics', async () => {
|
||||
const diacritics = 'áàéèíìóòúùñçÁÀÉÈÍÌÓÒÚÙÑÇ'
|
||||
const isUnique = jest.fn().mockResolvedValue(true)
|
||||
await expect(uniqueSlug(enya, isUnique)).resolves.toEqual('n')
|
||||
await expect(uniqueSlug(diacritics, isUnique)).resolves.toEqual('aaeeiioouuncaaeeiioouunc')
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user