diff --git a/slugify.js b/slugify.js index 160e9c0..f861995 100644 --- a/slugify.js +++ b/slugify.js @@ -28,7 +28,7 @@ var replacement = options.replacement === undefined ? '-' : options.replacement - var slug = string.normalize().split('') + var slug = Array.from(string.normalize()) // replace characters based on charMap .reduce(function (result, ch) { return result + (locale[ch] || charMap[ch] || ch) diff --git a/test/slugify.js b/test/slugify.js index 14f182c..5a4249b 100644 --- a/test/slugify.js +++ b/test/slugify.js @@ -249,6 +249,16 @@ describe('slugify', () => { t.equal(slugify('unicode ♥ is ☢'), 'unicode-love-is') }) + it('replace characters made up of multiple code units', () => { + slugify.extend({'🚣': 'person-rowing-boat'}) + t.equal(slugify('she is a 🚣'), 'she-is-a-person-rowing-boat') + + delete require.cache[require.resolve('../')] + slugify = require('../') + + t.equal(slugify('she is a 🚣'), 'she-is-a') + }) + it('normalize', () => { var slug = decodeURIComponent('a%CC%8Aa%CC%88o%CC%88-123') // åäö-123 t.equal(slugify(slug, {remove: /[*+~.()'"!:@]/g}), 'aao-123')