Skip to content

Commit

Permalink
fix: add ة،ء missing Arabic characters (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tokyo authored and Trott committed Oct 13, 2020
1 parent 8403bef commit 0366d3a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions slug.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@
ه: 'h',
و: 'o',
ي: 'y',
ء: 'aa',
ة: 'a',
// farsi
آ: 'a',
ا: 'a',
Expand Down
40 changes: 39 additions & 1 deletion test/slug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,45 @@ describe('slug', function () {
assert.strictEqual(slug(text, { mode: 'rfc3986', lower: false }), expected)
})

it('should replace arabic characters', function () { assert.strictEqual(slug('مرحبا بك'), 'mrhba-bk') })
it('should replace arabic characters', function () {
assert.strictEqual(slug('مرحبا بك'), 'mrhba-bk')
const charMap = {
أ: 'a',
ب: 'b',
ت: 't',
ث: 'th',
ج: 'g',
ح: 'h',
خ: 'kh',
د: 'd',
ذ: 'th',
ر: 'r',
ز: 'z',
س: 's',
ش: 'sh',
ص: 's',
ض: 'd',
ط: 't',
ظ: 'th',
ع: 'aa',
غ: 'gh',
ف: 'f',
ق: 'k',
ك: 'k',
ل: 'l',
م: 'm',
ن: 'n',
ه: 'h',
و: 'o',
ي: 'y',
ء: 'aa',
ة: 'a'
}
for (let char in charMap) { // eslint-disable-line prefer-const
const replacement = charMap[char]
assert.strictEqual(slug('foo' + char + ' bar baz'), 'foo' + replacement.toLowerCase() + '-bar-baz', 'replacing \'' + char + '\'')
}
})

it('should replace zh characters', function () { assert.strictEqual(slug('鳄梨'), '6boe5qko') })

Expand Down

0 comments on commit 0366d3a

Please sign in to comment.