From 9112d4a34fabbc6e3a17d17c91cfd404a4b7b481 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 7 Sep 2020 09:33:35 +0300 Subject: [PATCH] endpoint routing fix --- .../src/net/osmand/plus/server/OsmAndHttpServer.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java b/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java index 36685218e4..7e754661d7 100644 --- a/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java +++ b/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java @@ -52,13 +52,10 @@ public class OsmAndHttpServer extends NanoHTTPD { private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) { String uri = session.getUri(); - int pathEnd = uri.indexOf("/", 1); - if (pathEnd != -1) { - uri = uri.substring(0, pathEnd); - } - ApiEndpoint endpoint = endpoints.get(uri); - if (endpoint != null) { - return endpoint.process(session); + for (String path : endpoints.keySet()){ + if (uri.startsWith(path)) { + return endpoints.get(path).process(session); + } } return ErrorResponses.response404; }