From 9026305c2a8c146ee07738a7d3fce1bb53989c2b Mon Sep 17 00:00:00 2001 From: Morten Hansen Date: Tue, 7 Nov 2023 16:30:35 +0700 Subject: [PATCH] fix: handle versions in subpaths --- .../org/hisp/dhis/webapi/controller/RouteController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/RouteController.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/RouteController.java index 31ff7b804c62..9445d792e8b7 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/RouteController.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/RouteController.java @@ -91,9 +91,13 @@ public ResponseEntity runWithSubpath( private Optional getSubPath(String path, String id) { String prefix = String.format("%s/%s/run/", RouteSchemaDescriptor.API_ENDPOINT, id); - if (path.startsWith(prefix)) { + + if (path.startsWith(prefix, 3)) { + return Optional.of(path.substring(prefix.length() + 3)); + } else if (path.startsWith(prefix)) { return Optional.of(path.substring(prefix.length())); } + return Optional.empty(); } }