Class UriEncoder

java.lang.Object
co.yellowdog.platform.clients.web.uri.UriEncoder

public class UriEncoder extends Object
  • Constructor Details

    • UriEncoder

      public UriEncoder()
  • Method Details

    • encode

      public static String encode(String input)
      Encodes the given input string for use in either a path segment or a query param value.

      Note this method is not intended to be used on a full URI, a full path, or a full query string. Doing so will result in separators in those elements being encoded. For example, if the input is "foo/bar" then the output will be "foo%2Fbar". Instead, each segment should be encoded separately.

      The input string is encoded using UTF-8 as this is recommended.

      The output is nearly equivalent to URLEncoder.encode(String, String). However, that method encodes spaces as +, which is valid for query param values but not for path segments. %20 is valid in both contexts so this is used instead of +.

      Parameters:
      input - the path segment or query param value to encode
      Returns:
      the encoded string