Class UriUtils

java.lang.Object
dev.langchain4j.internal.UriUtils

public final class UriUtils extends Object
Utility class for URI operations.
  • Method Details

    • createUriSafely

      public static URI createUriSafely(String uriString)
      Creates a URI from the given string, handling illegal characters safely.

      This method first attempts to create a URI directly. If that fails due to illegal characters (such as spaces, non-ASCII characters, or characters like |), it will percent-encode only the illegal characters while preserving URL structural characters (:, /, etc.).

      If the input is null or blank, this method returns null. If the URI cannot be created even after encoding, null is returned.

      Parameters:
      uriString - the input string to convert to a URI
      Returns:
      a URI object, or null if the input is null, blank, or cannot be parsed