android/sdk/src/main/java/io/o2mc/sdk/util/Util.java
public static boolean isValidEndpoint(String endpoint) {
    if (endpoint == null || endpoint.isEmpty()) {
      return false;
    }

    // Check if we have a valid web / online url
    String webUrlPattern =
        "(?i)^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$";

    boolean isValidWebEndpoint = endpoint.matches(webUrlPattern);
    if (isValidWebEndpoint) {
      // Check if using HTTP or HTTPS
      if (!isHttps(endpoint)) {
        LogW(TAG,
            "validEndpointFormat: Endpoint is valid, but detected usage of HTTP instead of HTTPS. It is strongly recommended to use HTTPS in production usage.");
      }
      LogD(TAG, "validEndpointFormat: Valid web url '%s'");
      return true;
    }

    String localUrlPattern = "^\\w{4,5}://\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b.*";
    boolean isValidLocalEndpoint = endpoint.matches(localUrlPattern);
    if (isValidLocalEndpoint) {
      LogD(TAG, "validEndpointFormat: Valid local url.");
      return true;
    }

    // No valid pattern matches found
    return false;
  }
/**
   * Checks whether or not the provided endpoint is in valid format.
   * This does not check whether or not the endpoint actually exists / is online.
   *
   * @param endpoint URL pointing to a backend
   * @return true if the parameter is valid
   */
Checks whether or not the provided endpoint is in valid format.
This does not check whether or not the endpoint actually exists / is online.

@param endpoint URL pointing to a backend
@return true if the parameter is valid
Checks whether or not the provided endpoint is in valid format . This does not check whether or not the endpoint actually exists / is online . @param endpoint URL pointing to a backend @return true if the parameter is valid
public static boolean isValidEndpoint(String endpoint) {
    if (endpoint == null || endpoint.isEmpty()) {
      return false;
    }
    String webUrlPattern =
        "(?i)^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$";
    boolean isValidWebEndpoint = endpoint.matches(webUrlPattern);
    if (isValidWebEndpoint) {
      if (!isHttps(endpoint)) {
        LogW(TAG,
            "validEndpointFormat: Endpoint is valid, but detected usage of HTTP instead of HTTPS. It is strongly recommended to use HTTPS in production usage.");
      }
      LogD(TAG, "validEndpointFormat: Valid web url '%s'");
      return true;
    }
    String localUrlPattern = "^\\w{4,5}://\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b.*";
    boolean isValidLocalEndpoint = endpoint.matches(localUrlPattern);
    if (isValidLocalEndpoint) {
      LogD(TAG, "validEndpointFormat: Valid local url.");
      return true;
    }
    return false;
  }
public static boolean isValidEndpoint ( String endpoint ) { if ( endpoint == null || endpoint . isEmpty ( ) ) { return false ; } String webUrlPattern = "(?i)^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?$" ; boolean isValidWebEndpoint = endpoint . matches ( webUrlPattern ) ; if ( isValidWebEndpoint ) { if ( ! isHttps ( endpoint ) ) { LogW ( TAG , "validEndpointFormat: Endpoint is valid, but detected usage of HTTP instead of HTTPS. It is strongly recommended to use HTTPS in production usage." ) ; } LogD ( TAG , "validEndpointFormat: Valid web url '%s'" ) ; return true ; } String localUrlPattern = "^\\w{4,5}://\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b.*" ; boolean isValidLocalEndpoint = endpoint . matches ( localUrlPattern ) ; if ( isValidLocalEndpoint ) { LogD ( TAG , "validEndpointFormat: Valid local url." ) ; return true ; } return false ; }
Checks whether or not the provided endpoint is in valid format.
Checks whether or not the provided endpoint is in valid format .
// Check if we have a valid web / online url // Check if using HTTP or HTTPS // No valid pattern matches found