Skip to content

Commit

Permalink
Allow redirect on URL validator
Browse files Browse the repository at this point in the history
Solves #41
  • Loading branch information
renatocjn committed Apr 20, 2023
1 parent 3e98073 commit 8e73ece
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ public boolean checkForOkUrlEndpoint(String url) throws WebPageCheckerException
if (newUrl.toLowerCase().startsWith("https") &&
url.toLowerCase().startsWith("http") &&
newUrl.substring(5).equals(url.substring(4))) {
throw new WebPageCheckerException("It seems that a https rewrite is in place. Use https instead of http.");
} else {
throw new WebPageCheckerException(
String.format("An URL rewrite is in place. The new URL is %s. You should rewrite your URL pattern.",
newUrl)
);
"It seems that a https rewrite is in place. " +
"Use https instead of http.");
}
}
if (!status.is2xxSuccessful()) {
if (!status.is2xxSuccessful() && !status.is3xxRedirection()) {
throw new WebPageCheckerException(
String.format("'%s' returned status code %d, it must return 200", url, status.value()));
String.format("'%s' returned invalid status code status code %d, " +
"should be a successful (2xx) or redirect (3xx) code", url, status.value()));
}
return true;
}
Expand Down

0 comments on commit 8e73ece

Please sign in to comment.