You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "imbajin (via GitHub)" <gi...@apache.org> on 2024/07/31 08:35:05 UTC

Re: [PR] feat(common): add a tool method encode [incubator-hugegraph-commons]

imbajin commented on code in PR #146:
URL: https://github.com/apache/incubator-hugegraph-commons/pull/146#discussion_r1698120531


##########
hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java:
##########
@@ -414,10 +416,9 @@ public void close() {
 
     public static String encode(String raw) {
         try {
-            URI uri = new URI(null, null, raw, null);
-            return uri.toASCIIString();
-        } catch (URISyntaxException e) {
-            throw new IllegalArgumentException("Failed to encode string: " + raw, e);
+            return URLEncoder.encode(raw, StandardCharsets.UTF_8.toString()).replace("+", "%20");

Review Comment:
   Consider a better way to handle the case here



-- 
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: dev-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org