mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-14 20:39:59 -05:00
parent
76dcf90340
commit
22d8aad598
3 changed files with 9 additions and 9 deletions
|
@ -19,6 +19,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
|
|||
|
||||
### Improved
|
||||
- Bangumi search now shows the score and summary of a search result ([@MajorTanya](https://github.com/MajorTanya)) ([#1396](https://github.com/mihonapp/mihon/pull/1396))
|
||||
- Extension repo URLs are now auto-formatted ([@AntsyLich](https://github.com/AntsyLich), [@MajorTanya](https://github.com/MajorTanya))
|
||||
|
||||
## [v0.17.0] - 2024-10-26
|
||||
### Added
|
||||
|
|
|
@ -5,6 +5,7 @@ import mihon.domain.extensionrepo.exception.SaveExtensionRepoException
|
|||
import mihon.domain.extensionrepo.model.ExtensionRepo
|
||||
import mihon.domain.extensionrepo.repository.ExtensionRepoRepository
|
||||
import mihon.domain.extensionrepo.service.ExtensionRepoService
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
|
||||
class CreateExtensionRepo(
|
||||
|
@ -13,12 +14,13 @@ class CreateExtensionRepo(
|
|||
) {
|
||||
private val repoRegex = """^https://.*/index\.min\.json$""".toRegex()
|
||||
|
||||
suspend fun await(repoUrl: String): Result {
|
||||
if (!repoUrl.matches(repoRegex)) {
|
||||
return Result.InvalidUrl
|
||||
}
|
||||
suspend fun await(indexUrl: String): Result {
|
||||
val formattedIndexUrl = indexUrl.toHttpUrlOrNull()
|
||||
?.toString()
|
||||
?.takeIf { it.matches(repoRegex) }
|
||||
?: return Result.InvalidUrl
|
||||
|
||||
val baseUrl = repoUrl.removeSuffix("/index.min.json")
|
||||
val baseUrl = formattedIndexUrl.removeSuffix("/index.min.json")
|
||||
return service.fetchRepoDetails(baseUrl)?.let { insert(it) } ?: Result.InvalidUrl
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mihon.domain.extensionrepo.service
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
|
@ -21,11 +20,9 @@ class ExtensionRepoService(
|
|||
repo: String,
|
||||
): ExtensionRepo? {
|
||||
return withIOContext {
|
||||
val url = "$repo/repo.json".toUri()
|
||||
|
||||
try {
|
||||
with(json) {
|
||||
client.newCall(GET(url.toString()))
|
||||
client.newCall(GET("$repo/repo.json"))
|
||||
.awaitSuccess()
|
||||
.parseAs<ExtensionRepoMetaDto>()
|
||||
.toExtensionRepo(baseUrl = repo)
|
||||
|
|
Loading…
Reference in a new issue