Skip to content

Commit

Permalink
Fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
Semprini committed Mar 17, 2024
1 parent d858bc5 commit ee4b016
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mdg/tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def setUp(self):
def test_camel(self):
self.assertEqual("test", camelcase("test"))
self.assertEqual("test", camelcase("Test"))
self.assertEqual("test", camelcase("Test "))
self.assertEqual("test", camelcase("Test_"))
self.assertEqual("test", camelcase(" Test_"))
self.assertEqual("testCase", camelcase("TestCase"))
self.assertEqual("testCase", camelcase("testCase"))
self.assertEqual("testCase", camelcase("test case"))
Expand Down
2 changes: 1 addition & 1 deletion mdg/tools/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def camelcase(string:str) -> str:
if string is None or string == "":
return string
words: list = re.split(' |_', string)
words: list = re.split(' |_', string.strip(' _'))

# Can't use Title function in str library as this lowers all but the first char: does not handle existing camelCased input
words_camel: list = [(words[0][0].lower() + words[0][1:])] + list(word[0].upper() + word[1:] for word in words[1:])
Expand Down

0 comments on commit ee4b016

Please sign in to comment.