Skip to content

Commit

Permalink
fix: not using numbers as separators in capitalizeEachWords (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jooy2 committed Oct 25, 2024
1 parent fdda988 commit ef0b389
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.28.0 (2024-10-25)

- Not using numbers as separators in `capitalizeEachWords` (#185)

## 1.27.1 (2024-09-26)

- Fix `sortMenusByFrontmatterOrder` not been sorted in numerical order but in string order (@Cryolitia)
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ export default class VitePressSidebar {
let lastChar = '';

for (let i = 0; i < text.length; i += 1) {
if ((i === 0 || !/[a-zA-Z]/.test(lastChar)) && /[a-z]/.test(text[i])) {
if ((i === 0 || !/[a-zA-Z0-9]/.test(lastChar)) && /[a-z]/.test(text[i])) {
text = text.slice(0, i) + text[i].toUpperCase() + text.slice(i + 1);
}

Expand Down
1 change: 1 addition & 0 deletions test/resources/capitalize/abc1def2g.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
empty file
4 changes: 4 additions & 0 deletions test/specs/options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,10 @@ describe('Test: APIs', () => {
{
text: 'A Hello World Abc-Def',
link: '/2'
},
{
text: 'Abc1def2g',
link: '/abc1def2g'
}
]
);
Expand Down

0 comments on commit ef0b389

Please sign in to comment.