From: David ‘Bombe’ Roden Date: Wed, 9 Nov 2016 20:30:26 +0000 (+0100) Subject: Only hide URL parameters in tooltip X-Git-Tag: 0.9.7^2~463 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=9f476fcc545db4703bad74cf7c3e78e0c57a9eb1;p=Sone.git Only hide URL parameters in tooltip --- 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