code: public static URI getCanonicalURI(String uriString, boolean canonicalizePath) {
          if ((uriString != null) && !"".equals(uriString)) {
              return getCanonicalURI(URI.create(uriString), canonicalizePath);
          }
          return null;
      }
docs: Create a canonical URI from a given URI.   A canonical URI is a URI with:<ul>
  <li>the host part of the authority lower-case since URI semantics dictate that hostnames are case insensitive
  <li>(optionally, NOT appropriate for Origin headers) the path part set to "/" if there was no path in the
  input URI (this conforms to the WebSocket and HTTP protocol specifications and avoids us having to do special
  handling for path throughout the server code).
  </ul>
  @param uriString         the URI to canonicalize, in string form
  @param canonicalizePath  if true, append trailing '/' when missing
  @return a URI with the host part of the authority lower-case and (optionally) trailing / added, or null if the uri is null
  @throws IllegalArgumentException if the uriString is not valid syntax