Skip to content

Commit 313a20b

Browse files
committed
Fix camelize special case
1 parent 84da5a7 commit 313a20b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drf_simple_api_errors/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def underscore_to_camel(match: re.Match) -> str:
2929
if len(group) == 3:
3030
return group[0] + group[2].upper()
3131
else:
32-
return group[1].upper()
32+
return group
3333

3434
if not api_settings.CAMELIZE:
3535
return s

tests/test_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class TestCamelize:
1515
("family_tree_name", "familyTreeName"),
1616
("very_long_last_name_and_first_name", "veryLongLastNameAndFirstName"),
1717
# This is a special case where the underscore is at the start
18-
# and should be removed, and the next character should be capitalized.
19-
("_special", "Special"),
18+
# and should NOT be removed.
19+
("_special", "_special"),
2020
],
2121
)
2222
def test_with_camelize_settings_true(self, mocker, field_input, expected_output):

0 commit comments

Comments
 (0)