fix: parse Base64-encoded update-source in release notes
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -250,9 +250,13 @@ class UpdateChecker(private val context: Context) {
|
||||
return false
|
||||
}
|
||||
|
||||
/** 从 release notes 的 HTML 注释里解析额外更新源(如自建 Gitea)。 */
|
||||
private fun parseUpdateSource(body: String): String? =
|
||||
Regex("""update-source:\s*(\S+)""").find(body)?.groupValues?.getOrNull(1)
|
||||
/** 从 release notes 的 HTML 注释里解析额外更新源(Base64 编码,兼容明文)。 */
|
||||
private fun parseUpdateSource(body: String): String? {
|
||||
val raw = Regex("""update-source:\s*(\S+)""").find(body)?.groupValues?.getOrNull(1) ?: return null
|
||||
// 尝试 Base64 解码;解码失败则原样返回(兼容明文)
|
||||
return runCatching { String(java.util.Base64.getDecoder().decode(raw), Charsets.UTF_8) }
|
||||
.getOrNull() ?: raw
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val GITHUB_API = "https://api.github.com/repos/lsxf/a2i/releases/latest"
|
||||
|
||||
Reference in New Issue
Block a user