refactor(titleCase): String index & String.substring()

- String.substr() is a deprecated API
- Convert the rest to lowercase
This commit is contained in:
MDLeom 2020-08-19 08:41:57 +00:00
parent 9490884b5a
commit 25aab0be28
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@
*/
hexo.extend.helper.register('titleCase', (str) => {
return str.replace(/[\w]+[^\s-]*/g, (match) => {
return match.charAt(0).toUpperCase() + match.substr(1)
return str.replace(/[\w]+[^\s]*/g, (match) => {
return match[0].toUpperCase() + match.substring(1).toLowerCase()
})
})