Skip to content

Commit 9927800

Browse files
committedJul 27, 2022
fix: ignore case changes for numbers
1 parent 2393fb0 commit 9927800

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Converts first character to lower case
6868

6969
- Splits string by the splitters provided (default: `['-', '_', '/', '.]`)
7070
- Splits when case changes from lower to upper or upper to lower
71+
- Ignores numbers for case changes
7172
- Case is preserved in returned value
7273
- Is an irreversible function since splitters are omitted
7374

‎src/index.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export function isUppercase (char: string = '') {
1+
const NUNBER_CHAR_RE = /[0-9]/
2+
3+
export function isUppercase (char: string = ''): boolean | null {
4+
if (NUNBER_CHAR_RE.test(char)) {
5+
return null
6+
}
27
return char.toUpperCase() === char
38
}
49

‎test/scule.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('splitByCase', () => {
99
FooBarBaz: ['Foo', 'Bar', 'Baz'],
1010
'foo_bar-baz/qux': ['foo', 'bar', 'baz', 'qux'],
1111
'foo--bar-Baz': ['foo', '', 'bar', 'Baz'],
12+
'foo123-bar': ['foo123', 'bar'],
1213
FOOBar: ['FOO', 'Bar'],
1314
ALink: ['A', 'Link']
1415
}

0 commit comments

Comments
 (0)
Please sign in to comment.