From 8e73ece929ba5af3c12f206dd7dbd866b0c847a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renato=20Jua=C3=A7aba=20Neto?= Date: Thu, 20 Apr 2023 10:46:18 +0100 Subject: [PATCH] Allow redirect on URL validator Solves #41 --- .../models/validators/WebPageCheckerDefault.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/identifiers/cloud/hq/ws/registry/models/validators/WebPageCheckerDefault.java b/src/main/java/org/identifiers/cloud/hq/ws/registry/models/validators/WebPageCheckerDefault.java index 0b3cd4b4..56a7331b 100644 --- a/src/main/java/org/identifiers/cloud/hq/ws/registry/models/validators/WebPageCheckerDefault.java +++ b/src/main/java/org/identifiers/cloud/hq/ws/registry/models/validators/WebPageCheckerDefault.java @@ -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; }