update from master
[fanfix.git] / library / WebLibraryServer.java
index 56d78ed4de20b5a52583af21105043a07cc8e89f..6260f6a5c6744d9c9411d0941ad3ad0a54c5e58b 100644 (file)
@@ -387,7 +387,11 @@ public class WebLibraryServer extends WebLibraryServerHtml {
        protected Response getCover(String uri, WLoginResult login)
                        throws IOException {
                String[] uriParts = uri.split("/");
+               int startAt = 0;
                int off = 2; // "" and "cover"
+               for (int i = 0; i < off; i++) {
+                       startAt += uriParts[i].length() + "/".length();
+               }
 
                if (uriParts.length < off + 2) {
                        return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST,
@@ -395,7 +399,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                }
 
                String type = uriParts[off + 0];
-               String id = uriParts[off + 1];
+               String id = uri.substring(startAt + type.length() + "/".length());
 
                InputStream in = null;
 
@@ -429,6 +433,10 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                        throws IOException {
                String[] uriParts = uri.split("/");
                int off = 2; // "" and "cover"
+               int startAt = 0;
+               for (int i = 0; i < off; i++) {
+                       startAt += uriParts[i].length() + "/".length();
+               }
 
                if (uriParts.length < off + 2) {
                        return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST,
@@ -446,7 +454,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                }
 
                String type = uriParts[off + 0];
-               String id = uriParts[off + 1];
+               String id = uri.substring(startAt + type.length() + "/".length());
 
                if ("source".equals(type)) {
                        sourceCover(id, login, luid);