pathSegments

Deprecated

`pathSegments` is deprecated. This property will contain an empty path segment at the beginning for URLs with a hostname, and an empty path segment at the end for the URLs with a trailing slash. If you need to keep this behaviour please use [rawSegments]. If you only need to access the meaningful parts of the path, consider using [segments] instead. Please decide if you need [rawSegments] or [segments] explicitly.

Replace with

rawSegments

A list containing the segments of the URL path.

This property was 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.pathSegments == listOf("", "docs", "")

val absolute = Url("/docs/")
absolute.pathSegments == listOf("", "docs", "")

val relative = Url("docs")
relative.pathSegments == listOf("docs")

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")

To address this issue, the current pathSegments property will be renamed to rawSegments.