Skip to content

Commit f0c0d42

Browse files
committed
Fix U.camelCase(string).
1 parent 39a2e73 commit f0c0d42

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/java/com/github/underscore/lodash/U.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ public static String camelCase(final String string) {
11911191
return createCompounder(new Function3<String, String, Integer, String>() {
11921192
public String apply(final String result, final String word, final Integer index) {
11931193
final String localWord = word.toLowerCase(Locale.getDefault());
1194-
return result + (index > 0 ? word.substring(0, 1).toUpperCase(Locale.getDefault())
1195-
+ word.substring(1) : localWord);
1194+
return result + (index > 0 ? localWord.substring(0, 1).toUpperCase(Locale.getDefault())
1195+
+ localWord.substring(1) : localWord);
11961196
}
11971197
}).apply(string);
11981198
}

src/test/java/com/github/underscore/lodash/StringTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void camelCase() {
6767
assertEquals("fooBar", U.chain("Foo Bar").camelCase().item());
6868
assertEquals("fooBar", U.camelCase("--foo-bar"));
6969
assertEquals("fooBar", U.camelCase("__foo_bar__"));
70+
assertEquals("ThisIsAnExampleString", U.upperFirst(U.camelCase("THIS_IS_AN_EXAMPLE_STRING")));
7071
assertEquals("", U.camelCase(null));
7172
assertEquals("a", U.camelCase("\u00c0"));
7273
}

0 commit comments

Comments
 (0)