Skip to content

Commit 7e83c0d

Browse files
committed
Moced urlEncode() to utils package.
1 parent 5c82b3e commit 7e83c0d

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/main/java/org/gitlab4j/api/AbstractApi.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.io.File;
44
import java.net.URL;
5-
import java.net.URLEncoder;
65

76
import javax.ws.rs.NotAuthorizedException;
87
import javax.ws.rs.core.Form;
@@ -14,6 +13,7 @@
1413
import org.gitlab4j.api.models.Group;
1514
import org.gitlab4j.api.models.Project;
1615
import org.gitlab4j.api.models.User;
16+
import org.gitlab4j.api.utils.UrlEncoder;
1717

1818
/**
1919
* This class is the base class for all the sub API classes. It provides implementations of
@@ -162,18 +162,7 @@ protected GitLabApiClient getApiClient() {
162162
* @throws GitLabApiException if encoding throws an exception
163163
*/
164164
protected String urlEncode(String s) throws GitLabApiException {
165-
try {
166-
String encoded = URLEncoder.encode(s, "UTF-8");
167-
// Since the encode method encodes plus signs as %2B,
168-
// we can simply replace the encoded spaces with the correct encoding here
169-
encoded = encoded.replace("+", "%20");
170-
encoded = encoded.replace(".", "%2E");
171-
encoded = encoded.replace("-", "%2D");
172-
encoded = encoded.replace("_", "%5F");
173-
return (encoded);
174-
} catch (Exception e) {
175-
throw new GitLabApiException(e);
176-
}
165+
return (UrlEncoder.urlEncode(s));
177166
}
178167

179168
/**

0 commit comments

Comments
 (0)