Skip to content

Commit 0a42565

Browse files
authored
Merge pull request #14764 from IgorKvasn/capitalize-fix
Fixed string capitalize for accented characters
2 parents 765e033 + 5c03a45 commit 0a42565

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/ember-runtime/lib/system/string.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const STRING_UNDERSCORE_REGEXP_2 = (/\-|\s+/g);
4242
const UNDERSCORE_CACHE = new Cache(1000, str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').
4343
replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase());
4444

45-
const STRING_CAPITALIZE_REGEXP = (/(^|\/)([a-z])/g);
45+
const STRING_CAPITALIZE_REGEXP = (/(^|\/)([a-z\u00C0-\u024F])/g);
4646

4747
const CAPITALIZE_CACHE = new Cache(1000, str => str.replace(STRING_CAPITALIZE_REGEXP, (match, separator, chr) => match.toUpperCase()));
4848

packages/ember-runtime/tests/system/string/capitalize_test.js

+7
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ QUnit.test('capitalize namespaced dasherized string', function() {
6464
deepEqual('private-docs/owner-invoice'.capitalize(), 'Private-docs/Owner-invoice');
6565
}
6666
});
67+
68+
QUnit.test('capitalize string with accent character', function() {
69+
deepEqual(capitalize('šabc'), 'Šabc');
70+
if (ENV.EXTEND_PROTOTYPES.String) {
71+
deepEqual('šabc'.capitalize(), 'Šabc');
72+
}
73+
});

0 commit comments

Comments
 (0)