Class URLPathEncoder
- java.lang.Object
-
- nonapi.io.github.classgraph.utils.URLPathEncoder
-
public final class URLPathEncoder extends java.lang.ObjectA simple URL path encoder.
-
-
Field Summary
Fields Modifier and Type Field Description private static char[]HEXADECIMALHexadecimal digits.private static boolean[]safeWhether an ASCII character is URL-safe.private static java.lang.String[]SCHEME_PREFIXESValid classpath URL scheme prefixes.
-
Constructor Summary
Constructors Modifier Constructor Description privateURLPathEncoder()Constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdecodePath(java.lang.String str)Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.static java.lang.StringencodePath(java.lang.String path)Encode a URL path using percent-encoding.static java.lang.StringnormalizeURLPath(java.lang.String urlPath)Normalize a URL path, so that it can be fed into the URL or URI constructor.private static voidunescapeChars(java.lang.String str, boolean isQuery, java.io.ByteArrayOutputStream buf)Unescape chars in a URL.
-
-
-
Method Detail
-
unescapeChars
private static void unescapeChars(java.lang.String str, boolean isQuery, java.io.ByteArrayOutputStream buf)Unescape chars in a URL. URLDecoder.decode is broken: https://bugs.openjdk.java.net/browse/JDK-8179507
-
decodePath
public static java.lang.String decodePath(java.lang.String str)
Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.- Parameters:
str- the str- Returns:
- the string
-
encodePath
public static java.lang.String encodePath(java.lang.String path)
Encode a URL path using percent-encoding. '/' is not encoded.- Parameters:
path- The path to encode.- Returns:
- The encoded path.
-
normalizeURLPath
public static java.lang.String normalizeURLPath(java.lang.String urlPath)
Normalize a URL path, so that it can be fed into the URL or URI constructor.- Parameters:
urlPath- the URL path- Returns:
- the URL string
-
-