if (name == null) {
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());
+ boolean fromPostingSone = ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) && linkMatchesPostingSone(context, link);
parts.add(new FreenetLinkPart(link, name, fromPostingSone));
} catch (MalformedURLException mue1) {
/* not a valid link, insert as plain text. */
Closer.close(bufferedReader);
}
}
+ removeTrailingWhitespaceParts(parts);
+ return parts;
+ }
+
+ private void removeTrailingWhitespaceParts(PartContainer parts) {
for (int partIndex = parts.size() - 1; partIndex >= 0; --partIndex) {
Part part = parts.getPart(partIndex);
if (!(part instanceof PlainTextPart) || !"\n".equals(part.getText())) {
}
parts.removePart(partIndex);
}
- return parts;
+ }
+
+ private boolean linkMatchesPostingSone(SoneTextParserContext context, String link) {
+ return (context != null) && (context.getPostingSone() != null) && link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId());
}
private int findNextWhitespace(String line) {