code: public static String normalizeHost(String host) {
          // if it is normalized IPv6 or could not be IPv6, return
          if (host.isEmpty() || host.charAt(0) == '[' || host.indexOf(':') < 0)
              return host;
  
          // normalize with [ ]
          return "[" + host + "]";
      }
docs: Normalize IPv6 address as per https://www.ietf.org/rfc/rfc2732.txt
  
  @param host A host name
  @return Host name surrounded by '[' and ']' as needed.