Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions avaje-jex/src/main/java/io/avaje/jex/routes/PathSegmentParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import java.util.regex.MatchResult;
import java.util.regex.Pattern;

import static java.util.stream.Collectors.toList;

final class PathSegmentParser {

private static final PathSegment WILDCARD = new PathSegment.Wildcard();

private static final String[] ADJACENT_VIOLATIONS = {"*{", "*<", "}*", ">*"};

private static final String NAME_STR = "[a-zA-Z0-9_-]+";
private static final String NAME_OPT = "([:][^/^{]+([{][0-9]+[}])?)?"; // Optional regex
private static final String SLASH_STR = "[<]" + NAME_STR + "[>]";
private static final String PARAM_STR = "[{]" + NAME_STR + NAME_OPT + "[}]";
private static final String NAME_STR = "[\\w-]+";
private static final String NAME_OPT = "(:[^/^{]+([{]\\d+})?)?"; // Optional regex
private static final String SLASH_STR = "<" + NAME_STR + ">";
private static final String PARAM_STR = "[{]" + NAME_STR + NAME_OPT + "}";
private static final String MULTI_STR = "(" + PARAM_STR + "|" + SLASH_STR + "|[*]|" + "[^{</*]+)";

private static final Pattern MATCH_PARAM = Pattern.compile(PARAM_STR);
Expand Down Expand Up @@ -93,9 +91,7 @@ static boolean matchParamWithRegex(String input) {
}

static List<String> multi(String input) {
return MATCH_MULTI.matcher(input).results()
.map(MatchResult::group)
.collect(toList());
return MATCH_MULTI.matcher(input).results().map(MatchResult::group).toList();
}

static boolean matchLiteral(String segment) {
Expand Down Expand Up @@ -130,5 +126,4 @@ boolean endCharOnly(char c) {
// last char matches and no prior matching char
return segment.indexOf(c) == segment.length() - 1;
}

}