Skip to content

Commit

Permalink
url validation updated to accept # symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
arul-fourseals committed Aug 8, 2024
1 parent c2bcc62 commit 77bb90a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private SimpleEntry<String, String> 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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,8 @@ private static Stream<Arguments> 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

Expand Down

0 comments on commit 77bb90a

Please sign in to comment.