resolve entry link when url is relative (fix #181)

This commit is contained in:
Athou
2013-05-26 07:28:32 +02:00
parent 122acfcf70
commit f04b24796c
5 changed files with 32 additions and 13 deletions

View File

@@ -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;
}
}