Closed sorenlouv closed 8 years ago
Yeah, makes sense. I just never considered that use-case. PR welcome for a fix :)
If this is fixed, what would be the expected output for camelCase('FBBazzy')
?
fbBazzy
probably
The changes I've made pass the following test cases including the previous ones without non basic plane characters.
t.is(fn('XMLHttpRequest'), 'xmlHttpRequest');
t.is(fn('AjaxXMLHttpRequest'), 'ajaxXmlHttpRequest');
t.is(fn('Ajax-XMLHttpRequest'), 'ajaxXmlHttpRequest');
It fails for this test case :
t.is(fn('FBBÈzzy'), 'fbbÈzzy');
This test case is t.is(fn('FBBÈzzy'), 'fBBÈzzy');
in the current version and passes because only the first character is compared. The current version produces the wrong answer when a character such as È occurs after a -
before the final step is run.
camelCase('Ab-Èb') == 'ab-èb'
This is down to the fact that Regexes before ES6 are not Unicode aware I presume ?
camelCase('Ab-Èb') == 'ab-èb'
For reference lodash.camelcase deburrs Latin-1 Supplement and Latin Extended-A block characters:
camelcase('Ab-Èb')
// => "abEb"
Subsequent uppercase letters in a string are not converted to lowercase.
Example: "XMLHttpRequest" is converted to "xMLHttpRequest" rather than "xmlHttpRequest".
Compared with Lodash
Is this the intended behaviour?