diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidator.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidator.java index 642588e6..e6da6264 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidator.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidator.java @@ -216,7 +216,7 @@ private SimpleEntry validateURL(GrantAdvertQuestionResponse ques // (incl. .com) (repeating) | // (optional) slash | (optional) additional path | (optional) slash | // (optional) query params - String urlValidPattern = "^(http://|https://)(www.)?((?!www)[a-zA-Z0-9\\-]{2,}+)(\\.[a-zA-Z0-9\\-]{2,})+(/)?(/[a-z0-9\\-._~%!$&'()*+,;=:@]+)*?(/)?(\\?[a-z0-9\\-._~%!$&'()*+,;=:@/]*)?$"; + String urlValidPattern = "^(http://|https://)(www.)?((?!www)[a-zA-Z0-9\\-]{2,}+)(\\.[a-zA-Z0-9\\-]{2,})+(/)?(/[a-z0-9\\-._~%!$&'()*+,;=:@#]+)*?(/)?(\\?[a-z0-9\\-._~%!$&'()*+,;=:@#/]*)?$"; Pattern pattern = Pattern.compile(urlValidPattern, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(question.getResponse()); diff --git a/src/test/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidatorTest.java b/src/test/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidatorTest.java index 3d5e622b..a525ddb4 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidatorTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/validation/validators/AdvertPageResponseValidatorTest.java @@ -928,7 +928,8 @@ private static Stream validUrls() { Arguments.of("https://www.google.co.uk/long/path?query=var&query2=var"), Arguments.of("http://www.google.co.uk/long/path?query=var&query2=var"), Arguments.of("https://google.co.uk/long/path?query=var&query2=var"), - Arguments.of("http://google.co.uk/long/path?query=var&query2=var")); + Arguments.of("http://google.co.uk/long/path?query=var&query2=var"), + Arguments.of("https://google.co.uk/competition/1989/overview/63441f1e-850b-4581-986d-cd2f6c6c226d#summary")); } // @formatter:on