Java Utililty Methods URL Sanitize

List of utility methods to do URL Sanitize

Description

The list of methods to do URL Sanitize are organized into topic(s).

Method

StringsanitizeUrlWithProtocol(String url, String defaultProtocol)
Sanitizes a given URL to include a protocol prefix.
if (url.contains("://") && url.indexOf('/') - 1 == url.indexOf("://")) {
    return url;
} else {
    return defaultProtocol + "://" + url;