MicroUtils/ktor/common/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/common/CorrectWebsocketUrl.kt
2020-09-22 12:20:22 +10:00

15 lines
320 B
Kotlin

package dev.inmo.micro_utils.ktor.common
private val schemaRegex = Regex("[^:]*//")
val String.asCorrectWebSocketUrl: String
get() = if (startsWith("ws")) {
this
} else {
if (contains("://")) {
replace(schemaRegex, "ws://")
} else {
"ws://$this"
}
}