package de.tsschulz.tt_tagebuch.shared.api

data class ApiConfig(
    val baseUrl: String,
)

fun ApiConfig.toAbsoluteUrl(relativeOrAbsolute: String): String {
    val t = relativeOrAbsolute.trim()
    if (t.startsWith("http://", ignoreCase = true) || t.startsWith("https://", ignoreCase = true)) {
        return t
    }
    val base = baseUrl.trimEnd('/')
    val path = if (t.startsWith("/")) t else "/$t"
    return base + path
}

fun memberProfileImagePath(clubId: Int, memberId: Int) = "/api/clubmembers/image/$clubId/$memberId"

