Skip to content

Commit

Permalink
Fix matrix TCKs
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Oct 24, 2023
1 parent 7bfe1e7 commit bba4aa7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions common/uri/src/main/java/io/helidon/common/uri/UriPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public interface UriPath {
* @return a new path representing the new relative path
*/
static UriPath createRelative(UriPath uriPath, String relativePath) {
if (uriPath instanceof UriPathMatrix) {
String rawPath = uriPath.rawPath();
int idx = rawPath.indexOf(relativePath);
rawPath = rawPath.substring(idx);
return new UriPathMatrix(rawPath, relativePath);
}
return new UriPathNoParam(uriPath.absolute(), relativePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class UriPathMatrix extends UriPathNoParam {
this.rawPath = rawPath;
}

UriPathMatrix(String rawPath, String noParamPath, UriPath absolute) {
super(noParamPath, absolute);
this.rawPath = rawPath;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class UriPathNoParam implements UriPath {
this.absolute = this;
}

UriPathNoParam(String rawPath, UriPath absolute) {
this.rawPath = rawPath;
this.absolute = absolute;
}

UriPathNoParam(UriPath absolute, String relativePath) {
this.rawPath = relativePath;
this.decodedPath = relativePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,11 @@ void testDoubleSlash(String rawPath) {
UriPath path = UriPath.create(rawPath);
assertThat(path.path(), is("/foo/bar"));
}

@Test
void testMatrix() {
UriPath raw = UriPath.create("/jaxrs_spec/resource/entitymatrix;param=ASDFGHJKLQWERTYUIOPPPPPPP");
UriPath relative = (UriPathMatrix) UriPath.createRelative(raw, "/resource/entitymatrix");
assertThat(relative.rawPath(), is("/resource/entitymatrix;param=ASDFGHJKLQWERTYUIOPPPPPPP"));
}
}

0 comments on commit bba4aa7

Please sign in to comment.