aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/util/MessageUtils.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-12-12 11:28:12 +0300
committerGravatar Vitaly Takmazov2019-12-12 11:28:12 +0300
commitf462d7335567960978e16c5e042c99b54daa94b6 (patch)
treef298f3ac50ed64d0292bba0a8a6e148e8daa434c /src/main/java/com/juick/util/MessageUtils.java
parentc0ae480bb5c07ea7b9e1b42df428e2857b0d4816 (diff)
Cleanup IDEA code issues
Diffstat (limited to 'src/main/java/com/juick/util/MessageUtils.java')
-rw-r--r--src/main/java/com/juick/util/MessageUtils.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/java/com/juick/util/MessageUtils.java b/src/main/java/com/juick/util/MessageUtils.java
index 9b668b7c..b922d980 100644
--- a/src/main/java/com/juick/util/MessageUtils.java
+++ b/src/main/java/com/juick/util/MessageUtils.java
@@ -28,6 +28,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -270,16 +271,12 @@ public class MessageUtils {
// TODO: check if it is really needed
public static String percentEncode(final String s) {
- String ret = StringUtils.EMPTY;
- try {
- ret = URLEncoder.encode(s, CharEncoding.UTF_8).replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
- } catch (UnsupportedEncodingException e) {
- }
- return ret;
+ return URLEncoder.encode(s, StandardCharsets.UTF_8).replace("+", "%20")
+ .replace("*", "%2A").replace("%7E", "~");
}
public static String formatMarkdownText(final Message msg) {
- String s = StringUtils.defaultString(msg.getText()).replaceAll(replyNumberRegex, String.format("$1[/$2](https://juick.com/m/%d#$2)$3", msg.getMid()));
- return escapeMarkdown(s);
+ return StringUtils.defaultString(msg.getText())
+ .replaceAll(replyNumberRegex, String.format("$1[/$2](https://juick.com/m/%d#$2)$3", msg.getMid()));
}
public static String escapeMarkdown(final String s) {
return s.replace("_", "\\_").replace("*", "\\*")