Skip to content

Commit bba938e

Browse files
DanielSeehausensindresorhus
authored andcommittedApr 1, 2019
Improve upper/lower case character detection (#49)
Fixes #42
1 parent 1f43e8a commit bba938e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const preserveCamelCase = string => {
2020
isLastCharUpper = false;
2121
isLastCharLower = true;
2222
} else {
23-
isLastCharLower = character.toLowerCase() === character;
23+
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
2424
isLastLastCharUpper = isLastCharUpper;
25-
isLastCharUpper = character.toUpperCase() === character;
25+
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
2626
}
2727
}
2828

‎test.js

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ test('camelCase', t => {
4747
t.is(camelCase('AjaxXMLHttpRequest'), 'ajaxXmlHttpRequest');
4848
t.is(camelCase('Ajax-XMLHttpRequest'), 'ajaxXmlHttpRequest');
4949
t.is(camelCase([]), '');
50+
t.is(camelCase('mGridCol6@md'), 'mGridCol6@md');
51+
t.is(camelCase('A::a'), 'a::a');
5052
});
5153

5254
test('camelCase with pascalCase option', t => {
@@ -95,6 +97,8 @@ test('camelCase with pascalCase option', t => {
9597
t.is(camelCase('AjaxXMLHttpRequest', {pascalCase: true}), 'AjaxXmlHttpRequest');
9698
t.is(camelCase('Ajax-XMLHttpRequest', {pascalCase: true}), 'AjaxXmlHttpRequest');
9799
t.is(camelCase([], {pascalCase: true}), '');
100+
t.is(camelCase('mGridCol6@md', {pascalCase: true}), 'MGridCol6@md');
101+
t.is(camelCase('A::a', {pascalCase: true}), 'A::a');
98102
});
99103

100104
test('invalid input', t => {

0 commit comments

Comments
 (0)
Please sign in to comment.