Skip to content

Commit

Permalink
Merge pull request #11 from 6akcuk/feature/cyrillic-support
Browse files Browse the repository at this point in the history
Add support to capitalize words with cyrillic characters
  • Loading branch information
grncdr authored Feb 12, 2020
2 parents 4ab69ae + 593e63f commit 00897c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ test('Capitalize words, preserving the case', function (t) {
})
```

```javascript
test('Capitalize words with cyrillic characters', function (t) {
t.plan(1)
t.equal(capitalize.words('привет мир'), "Привет Мир")
})
```

## Install

npm install capitalize
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports.words = function (string, preserve) {
if (!preserve) {
string = string.toLowerCase();
}
return string.replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) {
return string.replace(/(^|[^a-zA-Z\u00C0-\u017F\u0400-\u04FF'])([a-zA-Z\u00C0-\u017F\u0400-\u04FF])/g, function (m) {
return m.toUpperCase()
})
}

0 comments on commit 00897c4

Please sign in to comment.