garydgregory commented on code in PR #220:
URL: https://github.com/apache/commons-codec/pull/220#discussion_r1404348287
##########
src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java:
##########
@@ -126,10 +126,20 @@ public final String encode(String name) {
// Preprocessing
name = cleanName(name);
+ // Bulletproof if name becomes empty after cleanName(name)
+ if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) ||
name.length() == 0) {
+ return EMPTY;
+ }
+
// BEGIN: Actual encoding part of the algorithm...
// 1. Delete all vowels unless the vowel begins the word
name = removeVowels(name);
+ // Bulletproof if name becomes empty after removeVowels(name)
+ if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) ||
name.length() == 0) {
Review Comment:
Use `isEmpty()`.
##########
src/main/java/org/apache/commons/codec/language/MatchRatingApproachEncoder.java:
##########
@@ -126,10 +126,20 @@ public final String encode(String name) {
// Preprocessing
name = cleanName(name);
+ // Bulletproof if name becomes empty after cleanName(name)
+ if (EMPTY.equalsIgnoreCase(name) || SPACE.equalsIgnoreCase(name) ||
name.length() == 0) {
Review Comment:
Use `isEmpty()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]