Skip to content

Commit

Permalink
fix: wrong path in PathSupport when param has http scheme (#1683)
Browse files Browse the repository at this point in the history
Co-authored-by: dd.kim <dqrd1234@gmail.com>
  • Loading branch information
fucct and fucctt committed Jun 16, 2023
1 parent a1ccae1 commit ee77b10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class PathSupport {
return targetUri
}

def indexOfScheme = targetUri.indexOf("://");
def path = StringUtils.substringBefore(targetUri, "?")
def indexOfScheme = path.indexOf("://");
if (indexOfScheme == -1) {
def path = StringUtils.substringBefore(targetUri, "?")
return StringUtils.startsWith(path, "/") ? path : "/" + path
}
def indexOfPath = StringUtils.indexOf(targetUri, "/", indexOfScheme + 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,26 @@ public class PathSupportTest {
// Then
assertThat(path, is("/"));
}
}
@Test public void
returns_path_when_param_has_scheme() {
// Given
String targetUri = "/path?uri=http://localhost";

// When
String path = PathSupport.getPath(targetUri);

// Then
assertThat(path, is("/path"));
}
@Test public void
returns_path_when_path_is_fully_qualified_uri_and_param_has_scheme() {
// Given
String targetUri = "http://localhost/path?uri=http://localhost";

// When
String path = PathSupport.getPath(targetUri);

// Then
assertThat(path, is("/path"));
}
}

0 comments on commit ee77b10

Please sign in to comment.