[TEXT-189] Fix CaseUtils when the input string contains only delimiters#179
[TEXT-189] Fix CaseUtils when the input string contains only delimiters#179ZhuGongpu wants to merge 1 commit intoapache:masterfrom
Conversation
|
@ZhuGongpu great catch! Thanks for the pull request, and for updating the tests. I wonder if we could improve the Javadocs too? Maybe one more We will also need a JIRA for the changelog in the next release. Could you create one in https://issues.apache.org/jira/projects/TEXT/issues and update the title of this PR to @garydgregory, @chtompki, and others, I think this is a legit issue. Imagine you have two combo boxes in a web page, with name and surname, and for whatever reason you want to camel case the two. In But if the user does not select values, and there is no validation in the web page or on the server side, then the code called would have IMO, we should be consistent and always remove the delimiters (unless the given |
|
The existing method needs a review first IMO. For this patch though, I don't see why applying the function to a string should change its size, that's just weird to me. One problem I see with the current implementation is the use of the default character set in the call to toLowerCase(). At the very least, we need a test to account for the "Turkish Surprise", see https://garygregory.wordpress.com/2015/11/03/java-lowercase-conversion-turkey/ and see also the last comment about “Kedi”.toUpperCase() which I am not sure applies to title case. |
I think that's just the way it was designed. You provide the delimiters for each part of a camel-cased String. Say you have a snake-cased String IMHO, it's more intuitive to be consistent with the removal of delimiters for every non-empty String. So
+1 but I think this doesn't need to block this change, we can create a separate ticket about surrogate pairs in |
Gotcha, makes sense, I was thinking of the case of " " -> "", where a transformation took place and its not any more camel cased than before, which feels a bit misleading.
Agreed. |
c4253a6 to
684a971
Compare
684a971 to
cbdd488
Compare
Done. |
|
Merged in b35cb56, thanks @ZhuGongpu ! |
Given a
strthat only containsdelimiters, the output ofCaseUtils.toCamelCaseshould be"", instead of the originalstr.