From 9f476fcc545db4703bad74cf7c3e78e0c57a9eb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 9 Nov 2016 21:30:26 +0100 Subject: [PATCH] Only hide URL parameters in tooltip --- src/main/java/net/pterodactylus/sone/text/SoneTextParser.java | 5 +++-- src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java index ee89c05..a279a6d 100644 --- a/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java +++ b/src/main/java/net/pterodactylus/sone/text/SoneTextParser.java @@ -364,8 +364,9 @@ public class SoneTextParser implements Parser { private void renderFreenetLink(PartContainer parts, String link, LinkType linkType, @Nullable SoneTextParserContext context) { String name = link; + String linkWithoutParameters = link; if (name.indexOf('?') > -1) { - name = name.substring(0, name.indexOf('?')); + linkWithoutParameters = name = name.substring(0, name.indexOf('?')); } if (name.endsWith("/")) { name = name.substring(0, name.length() - 1); @@ -380,7 +381,7 @@ public class SoneTextParser implements Parser { name = link.substring(0, Math.min(9, link.length())); } boolean fromPostingSone = ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) && (context != null) && (context.getPostingSone() != null) && link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId()); - parts.add(new FreenetLinkPart(link, name, fromPostingSone)); + parts.add(new FreenetLinkPart(link, name, linkWithoutParameters, fromPostingSone)); } catch (MalformedURLException mue1) { /* not a valid link, insert as plain text. */ parts.add(new PlainTextPart(link)); diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index 40e8124..d5e234e 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -115,7 +115,7 @@ public class SoneTextParserTest { @Test public void nameOfFreenetLinkDoesNotContainUrlParameters() { Iterable parts = soneTextParser.parse("KSK@gpl.txt?max-size=12345", null); - assertThat("Part Text", convertText(parts), is("[KSK@gpl.txt?max-size=12345|gpl.txt|gpl.txt]")); + assertThat("Part Text", convertText(parts), is("[KSK@gpl.txt?max-size=12345|KSK@gpl.txt|gpl.txt]")); } @Test -- 2.7.4