Package libcore.net.url
Class UrlUtils
- java.lang.Object
-
- libcore.net.url.UrlUtils
-
public final class UrlUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringauthoritySafePath(String authority, String path)Returns a path that can be safely concatenated withauthority.static StringcanonicalizePath(String path, boolean discardRelativePrefix)Returns the path will relative path segments like ".." and "." resolved.static intfindFirstOf(String string, String chars, int start, int end)Returns the index of the first char ofcharsinstringbounded betweenstartandend.static StringgetSchemePrefix(String spec)Returns the scheme prefix like "http" from the URL spec, or null if the spec doesn't start with a scheme.static booleanisValidSchemeChar(int index, char c)
-
-
-
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 withauthority. If the authority is null or empty, this can be any path. Otherwise the paths run together likehttp://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)
-
-