From 72413a87b9ac2eb1ea7ec8cfa37cd3ca5d3e5f8b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 16 Aug 2016 07:15:46 +0200 Subject: [PATCH] Ignore commas at the end of links, too --- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 2 +- src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index 6752c12..dbfa0f3 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -321,7 +321,7 @@ public class SoneTextParser implements Parser { } private boolean isPunctuation(char character) { - return character == '.'; + return (character == '.') || (character == ','); } private static class NextLink { diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index fb66f86..1161b8d 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -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 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. -- 2.7.4