@Test public void isMatch_againstMultipleRules() { RequestFilter requestFilter = new RequestFilter(Arrays.asList( "/todos", "/todoscommentscomments/*/users" )); assertTrue(requestFilter.isMatch("https: assertTrue(requestFilter.isMatch("https: assertTrue(requestFilter.isMatch("/todos/1/")); assertTrue(requestFilter.isMatch("todos/1/")); assertTrue(requestFilter.isMatch("www.test.com/todos")); assertTrue(requestFilter.isMatch("www.test.com/todos/")); assertTrue(requestFilter.isMatch("todos?query=1")); assertFalse(requestFilter.isMatch("https: assertFalse(requestFilter.isMatch("https: assertTrue(requestFilter.isMatch("/todos/1/comments/1")); assertTrue(requestFilter.isMatch("/todos/1/comments/1/")); assertTrue(requestFilter.isMatch("https: assertTrue(requestFilter.isMatch("https: assertFalse(requestFilter.isMatch("https: assertFalse(requestFilter.isMatch("https: assertFalse(requestFilter.isMatch("/comments")); }
public boolean isMatch(@NonNull String url) { for (String r : regex) { String trimUrl = url.split("\\?")[0]; if (!trimUrl.endsWith("/")) { trimUrl = trimUrl + "/"; } if (trimUrl.matches(r)) { return true; } } return false; }
RequestFilter { public boolean isMatch(@NonNull String url) { for (String r : regex) { String trimUrl = url.split("\\?")[0]; if (!trimUrl.endsWith("/")) { trimUrl = trimUrl + "/"; } if (trimUrl.matches(r)) { return true; } } return false; } }
RequestFilter { public boolean isMatch(@NonNull String url) { for (String r : regex) { String trimUrl = url.split("\\?")[0]; if (!trimUrl.endsWith("/")) { trimUrl = trimUrl + "/"; } if (trimUrl.matches(r)) { return true; } } return false; } RequestFilter(@NonNull List<String> rules); }
RequestFilter { public boolean isMatch(@NonNull String url) { for (String r : regex) { String trimUrl = url.split("\\?")[0]; if (!trimUrl.endsWith("/")) { trimUrl = trimUrl + "/"; } if (trimUrl.matches(r)) { return true; } } return false; } RequestFilter(@NonNull List<String> rules); boolean isMatch(@NonNull String url); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
RequestFilter { public boolean isMatch(@NonNull String url) { for (String r : regex) { String trimUrl = url.split("\\?")[0]; if (!trimUrl.endsWith("/")) { trimUrl = trimUrl + "/"; } if (trimUrl.matches(r)) { return true; } } return false; } RequestFilter(@NonNull List<String> rules); boolean isMatch(@NonNull String url); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }