Class UrlUtils


  • public final class UrlUtils
    extends Object
    • Method Detail

      • canonicalizePath

        public static String canonicalizePath​(String path,
                                              boolean discardRelativePrefix)
        Returns the path will relative path segments like ".." and "." resolved. The returned path will not necessarily start with a "/" character. This handles ".." and "." segments at both the beginning and end of the path.
        Parameters:
        discardRelativePrefix - true to remove leading ".." segments from the path. This is appropriate for paths that are known to be absolute.
      • authoritySafePath

        public static String authoritySafePath​(String authority,
                                               String path)
        Returns a path that can be safely concatenated with authority. If the authority is null or empty, this can be any path. Otherwise the paths run together like http://android.comindex.html.
      • getSchemePrefix

        public static String getSchemePrefix​(String spec)
        Returns the scheme prefix like "http" from the URL spec, or null if the spec doesn't start with a scheme. Scheme prefixes match this pattern: alpha ( alpha | digit | '+' | '-' | '.' )* ':'
      • isValidSchemeChar

        public static boolean isValidSchemeChar​(int index,
                                                char c)
      • findFirstOf

        public static int findFirstOf​(String string,
                                      String chars,
                                      int start,
                                      int end)
        Returns the index of the first char of chars in string bounded between start and end. This returns end if none of the characters exist in the requested range.