mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
resolve entry link when url is relative (fix #181)
This commit is contained in:
@@ -76,7 +76,9 @@ public class FeedParser {
|
||||
|
||||
entry.setGuid(FeedUtils.truncate(item.getUri(), 2048));
|
||||
entry.setGuidHash(DigestUtils.sha1Hex(item.getUri()));
|
||||
entry.setUrl(FeedUtils.truncate(item.getLink(), 2048));
|
||||
entry.setUrl(FeedUtils.toAbsoluteUrl(
|
||||
FeedUtils.truncate(item.getLink(), 2048),
|
||||
feed.getLink()));
|
||||
entry.setUpdated(validateDate(getUpdateDate(item)));
|
||||
entry.setAuthor(FeedUtils.truncate(item.getAuthor(), 128));
|
||||
|
||||
|
||||
@@ -185,4 +185,23 @@ public class FeedUtils {
|
||||
Collections.reverse(timestamps);
|
||||
return timestamps;
|
||||
}
|
||||
|
||||
public static String removeTrailingSlash(String url) {
|
||||
if (url.endsWith("/")) {
|
||||
url = url.substring(0, url.length() - 1);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
public static String toAbsoluteUrl(String url, String baseUrl) {
|
||||
if (baseUrl == null || url == null || url.startsWith("http")) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (url.startsWith("/") == false) {
|
||||
url = "/" + url;
|
||||
}
|
||||
|
||||
return baseUrl + url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user