i2psnark: Fix buttons on torrent details page (JRE 21)

This commit is contained in:
zzz
2024-03-09 13:24:51 -05:00
parent 95abb93002
commit 6bb6210f70

View File

@@ -586,6 +586,17 @@ class BasicServlet extends HttpServlet
protected static String addPaths(String base, String path) {
if (path == null)
return base;
if (path.equals("/")) {
// Java 17 and below:
// (new File("foo", "/")).toString() = "foo/"
// (new File("foo/", "/")).toString() = "foo/"
// Java 21:
// (new File("foo", "/")).toString() = "foo"
// (new File("foo/", "/")).toString() = "foo"
if (base.endsWith("/"))
return base;
return base + path;
}
String rv = (new File(base, path)).toString();
if (SystemVersion.isWindows())
rv = rv.replace("\\", "/");