aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java')
-rw-r--r--juick-www/src/main/java/com/juick/www/WebApp.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/juick-www/src/main/java/com/juick/www/WebApp.java b/juick-www/src/main/java/com/juick/www/WebApp.java
index 85ae64d4..2f73229e 100644
--- a/juick-www/src/main/java/com/juick/www/WebApp.java
+++ b/juick-www/src/main/java/com/juick/www/WebApp.java
@@ -40,8 +40,10 @@ import ru.sape.Sape;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Stream;
/**
*
@@ -133,18 +135,18 @@ public class WebApp implements AutoCloseable {
public List<Tag> parseTags(String tagsStr) {
List<Tag> tags = new ArrayList<>();
- String tagsArr[];
if (tagsStr != null && !tagsStr.isEmpty()) {
- tagsArr = tagsStr.split("[ \\,]");
- for (int i = 0; i < tagsArr.length; i++) {
- if (tagsArr[i].startsWith("*")) {
- tagsArr[i] = tagsArr[i].substring(1);
+ Stream<String> tagsList = Arrays.stream(tagsStr.split("[ \\,]"))
+ .distinct().map( t -> {
+ if (t.startsWith("*")) {
+ t = t.substring(1);
}
- if (tagsArr[i].length() > 64) {
- tagsArr[i] = tagsArr[i].substring(0, 64);
+ if (t.length() > 64) {
+ t = t.substring(0, 64);
}
- }
- tags = tagService.getTags(tagsArr, true);
+ return t;
+ });
+ tags = tagService.getTags(tagsList.toArray(String[]::new), true);
while (tags.size() > 5) {
tags.remove(5);
}