Skip to content

Commit

Permalink
♻️ refactor: refactor logic for request4j #3
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed May 18, 2024
1 parent bb44ab2 commit 45636fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions plugin/src/main/groovy/org/unify4j/common/Request4j.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
Expand All @@ -24,7 +25,7 @@ public class Request4j {
* @param params A map containing query parameters to be appended to the URL.
* @return The URL string with appended query parameters.
*/
public static String appendQueryParams(String url, Map<String, Object> params) {
public static String appendQueryParams(String url, Map<String, Object> params) throws UnsupportedEncodingException {
if (Collection4j.isEmptyMap(params) || String4j.isEmpty(url)) {
return url;
}
Expand All @@ -38,8 +39,8 @@ public static String appendQueryParams(String url, Map<String, Object> params) {
builder.append('&');
}
String value = String.valueOf(params.get(param));
builder.append(URLEncoder.encode(param, StandardCharsets.UTF_8)).append('=');
builder.append(URLEncoder.encode(value, StandardCharsets.UTF_8));
builder.append(URLEncoder.encode(param, StandardCharsets.UTF_8.displayName())).append('=');
builder.append(URLEncoder.encode(value, StandardCharsets.UTF_8.displayName()));
}
return builder.toString();
}
Expand Down

0 comments on commit 45636fd

Please sign in to comment.