All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.routing.experimental.path-utils.kt Maven / Gradle / Ivy

There is a newer version: 5.35.2.0
Show newest version
package org.http4k.routing.experimental

internal fun String.pathJoin(suffix: String) = when {
    isEmpty() -> suffix
    suffix.isEmpty() -> this
    else -> "${withoutTrailingSlash()}/${suffix.withoutLeadingSlash()}"
}

internal fun String.withoutTrailingSlash() = if (endsWith("/")) dropLast(1) else this

internal fun String.withoutLeadingSlash() = if (startsWith("/")) drop(1) else this

internal fun String.withLeadingSlash() = if (startsWith("/")) this else "/$this"




© 2015 - 2024 Weber Informatics LLC | Privacy Policy