Class URLPathEncoder

java.lang.Object
nonapi.io.github.classgraph.utils.URLPathEncoder

public final class URLPathEncoder extends Object
A simple URL path encoder.
  • Field Details

    • safe

      private static boolean[] safe
      Whether an ASCII character is URL-safe.
    • HEXADECIMAL

      private static final char[] HEXADECIMAL
      Hexadecimal digits.
    • SCHEME_PREFIXES

      private static final String[] SCHEME_PREFIXES
      Valid classpath URL scheme prefixes.
  • Constructor Details

    • URLPathEncoder

      private URLPathEncoder()
      Constructor.
  • Method Details

    • unescapeChars

      private static void unescapeChars(String str, boolean isQuery, ByteArrayOutputStream buf)
      Unescape chars in a URL. URLDecoder.decode is broken: https://bugs.openjdk.java.net/browse/JDK-8179507
    • decodePath

      public static String decodePath(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 String encodePath(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 String normalizeURLPath(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