aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/util/MessageUtils.java
diff options
context:
space:
mode:
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("*", "\\*")