From b9f473bf09578bf61445ac7e3ba11a66cf57936c Mon Sep 17 00:00:00 2001 From: Vladimir Grinenko Date: Fri, 22 Apr 2016 02:06:14 +0300 Subject: [PATCH] Support for non-latin chars --- index.js | 3 +-- test/index.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4d07142..8ad871c 100644 --- a/index.js +++ b/index.js @@ -43,8 +43,7 @@ BananaSlug.prototype.reset = function () { var whitespace = /\s/g function slugger (string) { - var allowedCharacters = 'A-Za-z0-9_ -' - var re = new RegExp('[^' + allowedCharacters + ']', 'g') + var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g var maintainCase = false var replacement = '-' var result diff --git a/test/index.js b/test/index.js index 0b8dd5c..81d90b5 100644 --- a/test/index.js +++ b/test/index.js @@ -83,5 +83,10 @@ var testCases = [ mesg: 'deals with duplicates correctly-2', text: 'duplicate', slug: 'duplicate-2' + }, + { + mesg: 'deals with non-latin chars', + text: 'Привет', + slug: 'привет' } ]