Skip to content

Commit 22fbf30

Browse files
committed
fix: Windows file path
1 parent 42280b4 commit 22fbf30

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

yogurt/src/commonMain/kotlin/org/ntqqrev/yogurt/util/ResourceUtils.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ private val httpClient = createPlatformHttpClient()
2424
suspend fun resolveUri(uri: String): MediaSource = withContext(Dispatchers.IO) {
2525
when {
2626
uri.startsWith("file://") -> withFs {
27-
val filePath = Path(uri.removePrefix("file://").decodeURLPart())
27+
val pathStr = uri.removePrefix("file://").decodeURLPart()
28+
val normalizedPath = if (pathStr.startsWith("/") && pathStr.length > 2 && pathStr[1].isLetter() && pathStr[2] == ':') {
29+
pathStr.substring(1)
30+
} else {
31+
pathStr
32+
}
33+
val filePath = Path(normalizedPath)
2834
if (!exists(filePath)) {
2935
throw IOException("File not found: $filePath")
3036
}

0 commit comments

Comments
 (0)