code: private String encodeUrl(String text) {
      if (urlEncoding) {
        try {
          return URLEncoder.encode(text, "UTF-8");
        } catch (UnsupportedEncodingException e) {
          throw new ValidationException("UTF-8 encoding is not supported on this platform");
        }
      } else {
        // When encoding is disabled, we accept any character except '/'
        final String INVALID_CHAR = "/";
        if (text.contains(INVALID_CHAR)) {
          throw new ValidationException(
              "Invalid character \"" + INVALID_CHAR + "\" in path section \"" + text + "\".");
        }
        return text;
      }
    }
docs: =======