commonMain.com.copperleaf.ballast.navigation.routing.UnmatchedDestination.kt Maven / Gradle / Ivy
package com.copperleaf.ballast.navigation.routing
import io.ktor.http.Url
/**
* Represents a URL that was parsed, and can be used to match against a [Route] in a [RoutingTable].
*/
public data class UnmatchedDestination(
val originalDestinationUrl: String,
val matchablePathSegments: List,
val matchableQueryParameters: Map>,
public val extraAnnotations: Set,
) {
public companion object {
public fun parse(
destinationUrl: String,
extraAnnotations: Set = emptySet(),
): UnmatchedDestination {
val url = Url(destinationUrl)
val matchablePathSegments = url.pathSegments.dropWhile { it.isBlank() }.dropLastWhile { it.isBlank() }
val matchableQueryParameters = url.parameters.entries().associate { it.key to it.value }
return UnmatchedDestination(
originalDestinationUrl = destinationUrl,
matchablePathSegments = matchablePathSegments,
matchableQueryParameters = matchableQueryParameters,
extraAnnotations = extraAnnotations,
)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy