rawSegments
A list containing the segments of the URL path.
This property is designed to distinguish between absolute and relative paths, so it will have an empty segment at the beginning for URLs with a hostname and an empty segment at the end for URLs with a trailing slash.
val fullUrl = Url("http://ktor.io/docs/")
fullUrl.rawSegments == listOf("", "docs", "")
val absolute = Url("/docs/")
absolute.rawSegments == listOf("", "docs", "")
val relative = Url("docs")
relative.rawSegments == listOf("docs")
Content copied to clipboard
This behaviour may not be ideal if you're working only with full URLs. If you don't require the specific handling of empty segments, consider using the segments property instead:
val fullUrl = Url("http://ktor.io/docs/")
fullUrl.segments == listOf("docs")
val absolute = Url("/docs/")
absolute.segments == listOf("docs")
val relative = Url("docs")
relative.segments == listOf("docs")
Content copied to clipboard