Ignore commas at the end of links, too
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 16 Aug 2016 05:15:46 +0000 (07:15 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 16 Aug 2016 05:15:46 +0000 (07:15 +0200)
src/main/java/net/pterodactylus/sone/text/SoneTextParser.java
src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java

index 6752c12..dbfa0f3 100644 (file)
@@ -321,7 +321,7 @@ public class SoneTextParser implements Parser<SoneTextParserContext> {
        }
 
        private boolean isPunctuation(char character) {
-               return character == '.';
+               return (character == '.') || (character == ',');
        }
 
        private static class NextLink {
index fb66f86..1161b8d 100644 (file)
@@ -140,6 +140,14 @@ public class SoneTextParserTest {
                assertThat("Part Text", "Some text and a link: [http://example.sone/abc|example.sone/abc|example.sone/abc]... Nice!", is(convertText(parts, PlainTextPart.class, LinkPart.class)));
        }
 
+       @Test
+       public void commasAreIgnoredAtEndOfLinkBeforeWhitespace() {
+               SoneTextParser soneTextParser = new SoneTextParser(null, null);
+               Iterable<Part> parts = soneTextParser.parse("Some text and a link: http://example.sone/abc, nice!", null);
+               assertThat("Parts", parts, notNullValue());
+               assertThat("Part Text", "Some text and a link: [http://example.sone/abc|example.sone/abc|example.sone/abc], nice!", is(convertText(parts, PlainTextPart.class, LinkPart.class)));
+       }
+
        /**
         * Converts all given {@link Part}s into a string, validating that the
         * part’s classes match only the expected classes.