Class SCMUri


  • public final class SCMUri
    extends Object
    Utility class to help with SCM URI related things.
    Since:
    2.2.5
    • Method Detail

      • commonDefaultPorts

        public static Map<String,​Integer> commonDefaultPorts()
        Returns the common default ports.
        Returns:
        the common default ports.
      • normalize

        @CheckForNull
        public static String normalize​(@CheckForNull
                                       String uri)
        Normalize an URI. Normalization will apply the following changes:
        • The scheme will be forced to lowercase (scheme is case insensitive, so should not matter)
        • For schemes that use a hostname or user authority plus hostname format (such as ssh, http and https The hostname will be converted from IDNA to ASCII if necessary and forced to lowercase and the PCT-encoding of the user authority will be enforced (note that this may affect the case where a username in a user authority contains a : as the URI class does not provide a means to destructure and restructure a URI without encoding/decoding the username, consequently the %3A will be converted to : and not converted back)
        • Any redundant path navigation segments will be removed, for example a path of /foo/../bar will be normalized to /bar
        • Any trailing / will be removed
        Parameters:
        uri - the URI.
        Returns:
        the normalized api URI.
      • normalize

        @CheckForNull
        public static String normalize​(@CheckForNull
                                       String uri,
                                       Map<String,​Integer>... defaultPorts)
        Normalize an URI. Normalization will apply the following changes:
        • The scheme will be forced to lowercase (scheme is case insensitive, so should not matter)
        • For schemes in the supplied default ports that use a hostname or user authority plus hostname format (such as ssh, http and https The hostname will be converted from IDNA to ASCII if necessary and forced to lowercase and the PCT-encoding of the user authority will be enforced (note that this may affect the case where a username in a user authority contains a : as the URI class does not provide a means to destructure and restructure a URI without encoding/decoding the username, consequently the %3A will be converted to : and not converted back)
        • Any redundant path navigation segments will be removed, for example a path of /foo/../bar will be normalized to /bar
        • Any trailing / will be removed
        Parameters:
        uri - the URI
        defaultPorts - the URI scheme to default port mapping (a varargs list to make combination easier). Normally the caller would use commonDefaultPorts() as one of the arguments.
        Returns:
        the normalized api URI.