in java/com/google/gerrit/plugins/checks/UrlValidator.java [36:55]
public static String clean(String urlString) throws BadRequestException {
String trimmed = requireNonNull(urlString).trim();
if (trimmed.isEmpty()) {
return trimmed;
}
URI uri;
try {
uri = new URI(trimmed);
} catch (URISyntaxException e) {
logger.atFine().withCause(e).log("invalid URL: %s", urlString);
uri = null;
}
if (uri == null || Strings.isNullOrEmpty(uri.getScheme())) {
throw new BadRequestException("invalid URL: " + urlString);
}
if (!uri.getScheme().equals("http") && !uri.getScheme().equals("https")) {
throw new BadRequestException("only http/https URLs supported: " + urlString);
}
return trimmed;
}