From d95c298f0d97eaf511fb27a0c2d721570dbc0e69 Mon Sep 17 00:00:00 2001 From: dzikoysk Date: Sat, 7 Sep 2024 14:29:32 +0200 Subject: [PATCH] GH-2202 Automatically prefix routes with slash if missing (Resolve #2202) --- .../com/reposilite/token/infrastructure/RouteCommands.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reposilite-backend/src/main/kotlin/com/reposilite/token/infrastructure/RouteCommands.kt b/reposilite-backend/src/main/kotlin/com/reposilite/token/infrastructure/RouteCommands.kt index 3e7cf0116..09a8c9b96 100644 --- a/reposilite-backend/src/main/kotlin/com/reposilite/token/infrastructure/RouteCommands.kt +++ b/reposilite-backend/src/main/kotlin/com/reposilite/token/infrastructure/RouteCommands.kt @@ -59,6 +59,11 @@ internal class RouteAdd(private val accessTokenFacade: AccessTokenFacade) : Repo return } + if (!route.startsWith("/")) { + route = "/$route" + context.append("Provided route has been prefixed with /") + } + mappedPermissions.forEach { accessTokenFacade.addRoute(token.identifier, Route(route, it)) } context.append("Route $route has been added to token ${token.name}") }