lanraragi: FIX: 404 error when baseurl contains additional path (#9340)

This commit is contained in:
Troy Liu 2025-06-21 18:54:26 +08:00 committed by Draff
parent 2fd8684f2e
commit 6ee4ab2521
Signed by: Draff
GPG Key ID: E8A89F3211677653
2 changed files with 8 additions and 2 deletions

View File

@ -1,7 +1,7 @@
ext {
extName = 'LANraragi'
extClass = '.LANraragiFactory'
extVersionCode = 19
extVersionCode = 20
}
apply from: "$rootDir/common.gradle"

View File

@ -35,6 +35,7 @@ import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.IOException
import java.net.URL
import java.security.MessageDigest
import kotlin.math.max
@ -138,7 +139,12 @@ open class LANraragi(private val suffix: String = "") : ConfigurableSource, Unme
val archivePage = json.decodeFromString<ArchivePage>(response.body.string())
return archivePage.pages.mapIndexed { index, url ->
val uri = Uri.parse("${baseUrl}${url.trimStart('.')}")
var newUrl = url
val subPath = URL(baseUrl).path
if (!subPath.isNullOrEmpty()) {
newUrl = newUrl.replaceFirst(subPath, "")
}
val uri = Uri.parse("${baseUrl}${newUrl.trimStart('.')}")
Page(index, uri.toString(), uri.toString(), uri)
}
}