Foundations(iOS Sourceset): Provide implementation for makeAbsoluteIfRelativeUrl() in ServerInfoParser.ios.kt

This commit is contained in:
KotlinGeekDev
2026-01-26 20:08:44 +01:00
parent 94a5237eaa
commit fb5288d5f1
@@ -20,9 +20,29 @@
*/
package com.vitorpamplona.quartz.nip96FileStorage.info
import platform.Foundation.NSURL
import platform.Foundation.NSURLComponents
actual fun makeAbsoluteIfRelativeUrl(
baseUrl: String,
potentiallyRelativeUrl: String,
): String {
TODO("Not yet implemented")
}
): String =
try {
val refUrl = NSURLComponents(potentiallyRelativeUrl)
if (refUrl.scheme != null) {
potentiallyRelativeUrl
} else {
val apiUrlComponents =
NSURLComponents(
uRL =
NSURL(
string = potentiallyRelativeUrl,
relativeToURL = NSURL(baseUrl, encodingInvalidCharacters = false),
),
resolvingAgainstBaseURL = true,
)
apiUrlComponents.string ?: throw Exception("URL resolution failed.")
}
} catch (e: Exception) {
potentiallyRelativeUrl
}