nastra commented on code in PR #15989:
URL: https://github.com/apache/iceberg/pull/15989#discussion_r3427365651


##########
core/src/main/java/org/apache/iceberg/rest/RESTUtil.java:
##########
@@ -169,6 +179,39 @@ public static String decodeString(String encoded) {
     return URLDecoder.decode(encoded, StandardCharsets.UTF_8);
   }
 
+  /**
+   * Encodes a string for use as a URL path segment per RFC 3986. Spaces are 
encoded as {@code %20}
+   * (not {@code +}), and other non-unreserved characters are percent-encoded.
+   *
+   * <p>{@link #decodePathSegment(String)} should be used to decode.
+   *
+   * @param segment string to encode
+   * @return percent-encoded string suitable for use in URL path segments
+   */
+  public static String encodePathSegment(String segment) {
+    Preconditions.checkArgument(segment != null, "Invalid string to encode: 
null");
+    return PercentCodec.RFC3986.encode(segment);
+  }
+
+  /**
+   * Decodes a URL path segment per RFC 3986. Unlike {@link 
#decodeString(String)}, this method does
+   * <b>not</b> treat {@code +} as a space — it is left as a literal {@code +} 
character.
+   *
+   * <p>Note: this method is introduced in this release but is not yet wired 
into server-side

Review Comment:
   I think we should aim for a solution that we can wire everywhere and that 
doesn't introduce a behavioral regression



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to