Skip to content

Commit

Permalink
Ignoring query parameters in URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Zaytsev committed Jun 21, 2017
1 parent 2281690 commit aa0c614
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public boolean isInRegistry(String url) {
private static boolean endpointMatches(String mockedEndpoint, String url) {
String regEx = toRegEx(mockedEndpoint);

return url.matches(".*" + regEx);
return url.matches(".*" + regEx + queryArguments());
}

private static String queryArguments() {
return "(\\?.*)?";
}

private static String toRegEx(String mockedEndpoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ public void inRegistry_Yes_PathParameters() throws Exception {
assertTrue(result);
}

@Test
public void inRegistry_Yes_QueryParameters() throws Exception {
// Given
MocksRegistry.setRegistry(new HashSet<>(asList(
"/path3/path4",
"/path1/path2"
)));

// When
boolean result = testee.isInRegistry("http://example.com/path3/path4?someArg=a&otherArg=b");

// Then
assertTrue(result);
}

@Test
public void inRegistry_No() throws Exception {
// Given
Expand Down

0 comments on commit aa0c614

Please sign in to comment.