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);
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));
@Test
public void nameOfFreenetLinkDoesNotContainUrlParameters() {
Iterable<Part> 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