Skip to content

Commit

Permalink
Merge pull request #2 from appunni-m/main
Browse files Browse the repository at this point in the history
Merge Netflix#3880 fix
  • Loading branch information
appunni-old authored Dec 4, 2023
2 parents 884a9fe + dec43ea commit dd00723
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,24 @@ public static String getLoopOverTaskRefNameSuffix(int iteration) {
public static String removeIterationFromTaskRefName(String referenceTaskName) {
String[] tokens = referenceTaskName.split(TaskUtils.LOOP_TASK_DELIMITER);
int length = tokens.length;
return length > 1 ? String.join(
TaskUtils.LOOP_TASK_DELIMITER,
Arrays.copyOf(tokens, length - 1)
) : referenceTaskName;

// Check if the last element is an integer
if (length > 1 && isInteger(tokens[length - 1])) {
// Join all elements except the last one
return String.join(TaskUtils.LOOP_TASK_DELIMITER, Arrays.copyOf(tokens, length - 1));
} else {
// No integer at the end, return the original string
return referenceTaskName;
}
}

// Helper method to check if a string is an integer
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
return true;
} catch (NumberFormatException e) {
return false;
}
}
}

0 comments on commit dd00723

Please sign in to comment.