Skip to content

Commit

Permalink
Fix Russian
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm authored Jan 8, 2019
1 parent 3633c89 commit 7dff96f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,12 @@ BananaSlug.prototype.reset = function () {

var whitespace = /\s/g

function lower (string) {
return string.toLowerCase()
}

function slugger (string, maintainCase) {
var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g
var replacement = '-'

if (typeof string !== 'string') return ''
if (!maintainCase) string = string.replace(/[A-Z]+/g, lower)
if (!maintainCase) string = string.toLowerCase()
return string.trim()
.replace(re, '')
.replace(emoji(), '')
Expand Down
5 changes: 5 additions & 0 deletions russian.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Профили пользователей

# Привет

# Привет-non-latin-你好
9 changes: 7 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var testCases = [
{
mesg: 'deals with non-latin chars',
text: 'Привет',
slug: 'Привет'
slug: 'привет'
},
// https://github.com/wooorm/gh-and-npm-slug-generation
{
Expand Down Expand Up @@ -160,7 +160,7 @@ var testCases = [
{
mesg: 'gh-and-npm-slug-generation-14',
text: 'Привет non-latin 你好',
slug: 'Привет-non-latin-你好'
slug: 'привет-non-latin-你好'
},
// https://github.com/chrisdickinson/emoji-slug-example
{
Expand All @@ -182,5 +182,10 @@ var testCases = [
mesg: 'emoji-slug-example-4',
text: ':ok_hand: :hatched_chick: Two in a row',
slug: 'ok_hand-hatched_chick-two-in-a-row'
},
{
mesg: 'Cyrillic',
text: 'Профили пользователей',
slug: 'профили-пользователей'
}
]

0 comments on commit 7dff96f

Please sign in to comment.