if (scheme.equals("http") || scheme.equals("https")) {
try {
return new URL(url.toURI().toASCIIString());
} catch (URISyntaxException e) {
MalformedURLException malformedURLException = new MalformedURLException(e.getMessage());
malformedURLException.initCause(e);
throw malformedURLException;
}
}
return url;
}