Changeset 13994 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/ChangesetCommentModel.java
r13109 r13994 8 8 9 9 import org.openstreetmap.josm.gui.util.ChangeNotifier; 10 import org.openstreetmap.josm.tools.Utils; 10 11 11 12 /** … … 45 46 */ 46 47 public List<String> findHashTags() { 47 return Arrays.stream(comment.split("\\s")).filter(s -> s.length() >= 2 && s.charAt(0) == '#').collect(Collectors.toList()); 48 return Arrays.stream(comment.split("\\s")) 49 .map(s -> Utils.strip(s, ",;")) 50 .filter(s -> s.matches("#[a-zA-Z][a-zA-Z_\\-0-9]+")) 51 .collect(Collectors.toList()); 48 52 } 49 53 } -
trunk/test/unit/org/openstreetmap/josm/gui/io/ChangesetCommentModelTest.java
r13109 r13994 40 40 model.setComment(" https://example.com/#map "); 41 41 assertEquals(Collections.emptyList(), model.findHashTags()); 42 model.setComment("#59606086"); 43 assertEquals(Collections.emptyList(), model.findHashTags()); 42 44 model.setComment(" #foo "); 43 45 assertEquals(Arrays.asList("#foo"), model.findHashTags()); 44 46 model.setComment(" #foo #bar baz"); 45 47 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags()); 48 model.setComment(" #foo, #bar, baz"); 49 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags()); 50 model.setComment(" #foo; #bar; baz"); 51 assertEquals(Arrays.asList("#foo", "#bar"), model.findHashTags()); 52 model.setComment("#hotosm-project-4773 #DRONEBIRD #OsakaQuake2018 #AOYAMAVISION"); 53 assertEquals(Arrays.asList("#hotosm-project-4773", "#DRONEBIRD", "#OsakaQuake2018", "#AOYAMAVISION"), model.findHashTags()); 46 54 } 47 55 }
Note:
See TracChangeset
for help on using the changeset viewer.