fix: Fix PathTemplate custom verb logic matching and instantiating by vam-google · Pull Request #244 · googleapis/api-common-java · GitHub
Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions build.gradle
6 changes: 4 additions & 2 deletions src/main/java/com/google/api/pathtemplate/PathTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ private boolean match(
switch (segments.get(i).kind()) {
case BINDING:
case END_BINDING:
// skip
case CUSTOM_VERB:
// These segments do not actually consume any input.
continue;
default:
segsToMatch++;
Expand Down Expand Up @@ -746,7 +747,8 @@ private String instantiate(Map<String, String> values, boolean allowPartial) {
while (iterator.hasNext()) {
Segment seg = iterator.next();
if (!skip && !continueLast) {
String separator = prevSeparator.isEmpty() ? seg.separator() : prevSeparator;
String separator =
prevSeparator.isEmpty() || !iterator.hasNext() ? seg.separator() : prevSeparator;
result.append(separator);
prevSeparator = seg.complexSeparator().isEmpty() ? seg.separator() : seg.complexSeparator();
}
Expand Down
70 changes: 70 additions & 0 deletions src/test/java/com/google/api/pathtemplate/PathTemplateTest.java