1
1
package org .gitlab4j .api .utils ;
2
2
3
3
import java .net .URLEncoder ;
4
-
5
- import org .gitlab4j .api .GitLabApiException ;
4
+ import java .nio .charset .StandardCharsets ;
6
5
7
6
public class UrlEncoder {
8
7
@@ -11,21 +10,16 @@ public class UrlEncoder {
11
10
*
12
11
* @param s the String to URL encode
13
12
* @return the URL encoded strings
14
- * @throws GitLabApiException if any exception occurs
15
13
*/
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 );
30
24
}
31
25
}
0 commit comments