Skip to content

Commit

Permalink
The string to shorten is now taken literal. Before it was compiled as…
Browse files Browse the repository at this point in the history
… a regex. We don't need that Complexity in that component.
  • Loading branch information
Feli499 committed Jan 7, 2024
1 parent bb6e75e commit b92548e
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -5,6 +5,7 @@
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.regex.Pattern;

public class PriorityItemDisplayNameShortener implements ItemDisplayNameShortener {

Expand Down Expand Up @@ -87,7 +88,7 @@ public String apply(String string) {

private record StringShortenerPair(String from, String to) implements Comparable<StringShortenerPair> {
public String apply(String string) {
return string.replaceAll("(?<=( |^))" + from + "(?=( |$))", to);
return string.replaceAll("(?<=( |^))" + Pattern.quote(from) + "(?=( |$))", to);
}

@Override
Expand Down

0 comments on commit b92548e

Please sign in to comment.