public static String formatIPAddressForURL(String ipAddress) {
    if (ipAddress.contains(":") && !ipAddress.startsWith("[") && !ipAddress.endsWith("]")) {
      // IPv6 address
      return "[" + ipAddress + "]";
    } else {
      // IPv4 address or hostname
      return ipAddress;
    }
  }
Prepares an IP address for use in a URL.
<p>
This method ensures that IPv6 addresses are enclosed in square brackets,
as required by URL syntax. IPv4 addresses and hostnames remain unchanged.
</p>

@param ipAddress the IP address or hostname to format
@return the formatted IP address for use in a URL
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/IPStackUtils.java