11package org .gitlab4j .api .utils ;
22
33import java .net .URLEncoder ;
4-
5- import org .gitlab4j .api .GitLabApiException ;
4+ import java .nio .charset .StandardCharsets ;
65
76public class UrlEncoder {
87
@@ -11,21 +10,16 @@ public class UrlEncoder {
1110 *
1211 * @param s the String to URL encode
1312 * @return the URL encoded strings
14- * @throws GitLabApiException if any exception occurs
1513 */
16- public static String urlEncode (String s ) throws GitLabApiException {
17-
18- try {
19- String encoded = URLEncoder .encode (s , "UTF-8" );
20- // Since the encode method encodes plus signs as %2B,
21- // we can simply replace the encoded spaces with the correct encoding here
22- encoded = encoded .replace ("+" , "%20" );
23- encoded = encoded .replace ("." , "%2E" );
24- encoded = encoded .replace ("-" , "%2D" );
25- encoded = encoded .replace ("_" , "%5F" );
26- return (encoded );
27- } catch (Exception e ) {
28- throw new GitLabApiException (e );
29- }
14+ public static String urlEncode (String s ) {
15+
16+ String encoded = URLEncoder .encode (s , StandardCharsets .UTF_8 );
17+ // Since the encode method encodes plus signs as %2B,
18+ // we can simply replace the encoded spaces with the correct encoding here
19+ encoded = encoded .replace ("+" , "%20" );
20+ encoded = encoded .replace ("." , "%2E" );
21+ encoded = encoded .replace ("-" , "%2D" );
22+ encoded = encoded .replace ("_" , "%5F" );
23+ return (encoded );
3024 }
3125}
0 commit comments