Top Description Fields Constructors Methods
nonapi.io.github.classgraph.utils

public final Class URLPathEncoder

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, java.nio.charset.StandardCharsets, nonapi.io.github.classgraph.utils.VersionFinder.OperatingSystem

A simple URL path encoder.

Field Summary

Modifier and TypeField and Description
private static final char[]
HEXADECIMAL

Hexadecimal digits.

private static boolean[]
safe

Whether an ASCII character is URL-safe.

private static final String[]
SCHEME_PREFIXES

Valid classpath URL scheme prefixes.

Constructor Summary

AccessConstructor and Description
private
URLPathEncoder()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the string
decodePath
(final String
the str
str
)

Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.

public static String

Returns:

The encoded path.
encodePath
(final String
The path to encode.
path
)

Encode a URL path using percent-encoding.

public static String

Returns:

the URL string
normalizeURLPath
(final String
the URL path
urlPath
)

Normalize a URL path, so that it can be fed into the URL or URI constructor.

private static void
unescapeChars(final String str, final boolean isQuery, final ByteArrayOutputStream buf)

Unescape chars in a URL.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEXADECIMALback to summary
private static final char[] HEXADECIMAL

Hexadecimal digits.

safeback to summary
private static boolean[] safe

Whether an ASCII character is URL-safe.

SCHEME_PREFIXESback to summary
private static final String[] SCHEME_PREFIXES

Valid classpath URL scheme prefixes.

Constructor Detail

URLPathEncoderback to summary
private URLPathEncoder()

Constructor.

Method Detail

decodePathback to summary
public static String decodePath(final String str)

Unescape a URL segment, and turn it from UTF-8 bytes into a Java string.

Parameters
str:String

the str

Returns:String

the string

encodePathback to summary
public static String encodePath(final String path)

Encode a URL path using percent-encoding. '/' is not encoded.

Parameters
path:String

The path to encode.

Returns:String

The encoded path.

normalizeURLPathback to summary
public static String normalizeURLPath(final String urlPath)

Normalize a URL path, so that it can be fed into the URL or URI constructor.

Parameters
urlPath:String

the URL path

Returns:String

the URL string

unescapeCharsback to summary
private static void unescapeChars(final String str, final boolean isQuery, final ByteArrayOutputStream buf)

Unescape chars in a URL. URLDecoder.decode is broken: https://bugs.openjdk.java.net/browse/JDK-8179507