Skip to content

Commit

Permalink
IQSS#9739 - URLValidator now allows two slashes in the path component…
Browse files Browse the repository at this point in the history
… of the URL
  • Loading branch information
luddaniel committed Aug 2, 2023
1 parent 54fd71e commit 69612d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static boolean isURLValid(String value) {
// default schemes == ValidateURL schemes() default
return isURLValid(value, new String[]{"http", "https", "ftp"});
}

/**
* Check if a URL is valid in a nullsafe way. (null = valid to allow optional values).
* Empty values are no valid URLs. This variant allows any schemes you hand over.
Expand All @@ -42,7 +42,7 @@ public static boolean isURLValid(String value) {
* @return true when valid (null is also valid) or false
*/
public static boolean isURLValid(String value, String[] schemes) {
UrlValidator urlValidator = new UrlValidator(schemes);
UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.ALLOW_2_SLASHES);
return value == null || urlValidator.isValid(value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static Stream<Arguments> stdUrlExamples() {
Arguments.of(true, "http://foobar.com:9101"),
Arguments.of(true, "ftp://user@foobar.com"),
Arguments.of(false, "cnn.com"),
Arguments.of(false, "smb://user@foobar.com")
Arguments.of(false, "smb://user@foobar.com"),
// case of a real permalink that requires UrlValidator.ALLOW_2_SLASHES
Arguments.of(true, "https://archive.softwareheritage.org/swh:1:dir:561bfe6698ca9e58b552b4eb4e56132cac41c6f9;origin=https://github.com/gem-pasteur/macsyfinder;visit=swh:1:snp:1bde3cb370766b10132c4e004c7cb377979928d1;anchor=swh:1:rev:868637fce184865d8e0436338af66a2648e8f6e1")
);
}

Expand Down

0 comments on commit 69612d6

Please sign in to comment.