Cyril Find
09/09/2025, 1:14 PMNavHost
to handle deeplinks with type safe generated routes but it breaks when there is a trailing slash, here’s a simple example:
@Serializable
data class CategoryScreen(val categoryPath: String) : AppNavigationScreen
composable<CategoryScreen>(deeplinks = listOf(
navDeepLink(basePath = "<myscheme://category>")
)) { ... }
// <myscheme://category/my-category> -> works ✅
// <myscheme://category/my-category/> -> doesn't ❌
anyone knows how to handle that properly ?Cyril Find
09/09/2025, 1:43 PMLaunchedEffect(Unit) {
if (intent.data?.path.orEmpty().endsWith("/")) {
val uri = intent.data?.buildUpon()?.path(intent.data.path?.removeSuffix("/"))?.build()
?: return
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
navController.handleDeepLink(intent)
}
}
Chrimaeon
09/10/2025, 3:23 PMmy-category
path the other one is accessing an empty path.
from https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
```A path consists of a sequence of path segments separated by a slash
("/") character. A path is always defined for a URI, though the
defined path may be empty (zero length)```
Chrimaeon
09/10/2025, 3:24 PM