Class URLPathEncoder
java.lang.Object
nonapi.io.github.classgraph.utils.URLPathEncoder
A simple URL path encoder.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char[]
Hexadecimal digits.private static boolean[]
Whether an ASCII character is URL-safe.private static final String[]
Valid classpath URL scheme prefixes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
decodePath
(String str) Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.static String
encodePath
(String path) Encode a URL path using percent-encoding.static String
normalizeURLPath
(String urlPath) Normalize a URL path, so that it can be fed into the URL or URI constructor.private static void
unescapeChars
(String str, boolean isQuery, ByteArrayOutputStream buf) Unescape chars in a URL.
-
Field Details
-
safe
private static boolean[] safeWhether an ASCII character is URL-safe. -
HEXADECIMAL
private static final char[] HEXADECIMALHexadecimal digits. -
SCHEME_PREFIXES
Valid classpath URL scheme prefixes.
-
-
Constructor Details
-
URLPathEncoder
private URLPathEncoder()Constructor.
-
-
Method Details
-
unescapeChars
Unescape chars in a URL. URLDecoder.decode is broken: https://bugs.openjdk.java.net/browse/JDK-8179507 -
decodePath
Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.- Parameters:
str
- the str- Returns:
- the string
-
encodePath
Encode a URL path using percent-encoding. '/' is not encoded.- Parameters:
path
- The path to encode.- Returns:
- The encoded path.
-
normalizeURLPath
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
-