Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
09aff841
Commit
09aff841
authored
Sep 09, 2019
by
Greg Messner
Browse files
Initial commit.
parent
7e83c0d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/utils/UrlEncoder.java
0 → 100644
View file @
09aff841
package
org.gitlab4j.api.utils
;
import
java.net.URLEncoder
;
import
org.gitlab4j.api.GitLabApiException
;
public
class
UrlEncoder
{
/**
* URL encodes a String in compliance with GitLabs special differences.
*
* @param s the String to URL encode
* @return the URL encoded strings
* @throws GitLabApiException if any exception occurs
*/
public
static
String
urlEncode
(
String
s
)
throws
GitLabApiException
{
try
{
String
encoded
=
URLEncoder
.
encode
(
s
,
"UTF-8"
);
// Since the encode method encodes plus signs as %2B,
// we can simply replace the encoded spaces with the correct encoding here
encoded
=
encoded
.
replace
(
"+"
,
"%20"
);
encoded
=
encoded
.
replace
(
"."
,
"%2E"
);
encoded
=
encoded
.
replace
(
"-"
,
"%2D"
);
encoded
=
encoded
.
replace
(
"_"
,
"%5F"
);
return
(
encoded
);
}
catch
(
Exception
e
)
{
throw
new
GitLabApiException
(
e
);
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment