Subject: [PATCH] Fix #23153: Remote Control API call is adding hashtags many times
---
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java b/src/org/openstreetmap/josm/gui/io/UploadDialogModel.java
a
|
b
|
|
78 | 78 | String hashtags = Arrays.stream(comment.split("\\s", -1)) |
79 | 79 | .map(s -> Utils.strip(s, ",;")) |
80 | 80 | .filter(s -> s.matches("#[a-zA-Z0-9][-_a-zA-Z0-9]+")) |
81 | | .collect(Collectors.joining(";")); |
| 81 | .distinct().collect(Collectors.joining(";")); |
82 | 82 | return hashtags.isEmpty() ? null : hashtags; |
83 | 83 | } |
84 | 84 | |
… |
… |
|
95 | 95 | if (hashtags != null) { |
96 | 96 | Set<String> sanitizedHashtags = new LinkedHashSet<>(); |
97 | 97 | for (String hashtag : hashtags.split(";", -1)) { |
98 | | sanitizedHashtags.add(hashtag.startsWith("#") ? hashtag : "#" + hashtag); |
| 98 | if (comment == null || !comment.contains(hashtag)) { |
| 99 | sanitizedHashtags.add(hashtag.startsWith("#") ? hashtag : "#" + hashtag); |
| 100 | } |
99 | 101 | } |
100 | 102 | if (!sanitizedHashtags.isEmpty()) { |
101 | 103 | result.append(' ').append(String.join(" ", sanitizedHashtags)); |