From 60bf0609626f36703a7bd5d940406d8d4fbe4cce Mon Sep 17 00:00:00 2001 From: Tlaster Date: Fri, 1 Dec 2023 17:16:32 +0900 Subject: [PATCH] disable path matching for group route --- docs/component/navigation.md | 1 + .../kotlin/moe/tlaster/precompose/navigation/RouteBuilder.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/component/navigation.md b/docs/component/navigation.md index 23b4ae30..a0356902 100644 --- a/docs/component/navigation.md +++ b/docs/component/navigation.md @@ -109,6 +109,7 @@ Optional syntax is also supported for regex path variable: `/user/{id:[0-9]+}?`: - matches `/user/123` ### Group +Note: group's `route` and `initialRoute` does not support path variable and regex, only static route is supported. ```kotlin group(route = "/group", initialRoute = "/nestedScreen1") { scene(route = "/nestedScreen1") { diff --git a/precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/RouteBuilder.kt b/precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/RouteBuilder.kt index feed09f9..f43839dc 100644 --- a/precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/RouteBuilder.kt +++ b/precompose/src/commonMain/kotlin/moe/tlaster/precompose/navigation/RouteBuilder.kt @@ -67,6 +67,8 @@ class RouteBuilder( initialRoute: String, content: RouteBuilder.() -> Unit, ) { + require(!route.contains("{")) { "GroupRoute does not support path matching" } + require(!initialRoute.contains("{")) { "GroupRoute does not support path matching" } content.invoke(this) val actualInitialRoute = this.route.firstOrNull { it.route == initialRoute } ?: throw IllegalArgumentException("Initial route $initialRoute not found")