From cdce2af4a3312cf826dcc112041a3628691d6c3d Mon Sep 17 00:00:00 2001 From: Koitharu Date: Thu, 7 Nov 2024 14:47:52 +0200 Subject: [PATCH] Fix nightly version name parsing --- .../main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt | 3 ++- .../main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt index d2605d7cb..9426401ae 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt @@ -1,5 +1,6 @@ package org.koitharu.kotatsu.core.github +import org.koitharu.kotatsu.core.util.ext.digits import java.util.Locale data class VersionId( @@ -48,7 +49,7 @@ fun VersionId(versionName: String): VersionId { return VersionId( major = 0, minor = 0, - build = versionName.drop(1).toIntOrNull() ?: 0, + build = versionName.digits().toIntOrNull() ?: 0, variantType = "n", variantNumber = 0, ) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt index 1b4917bd4..3294e66fb 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt @@ -28,6 +28,8 @@ fun String.toUUIDOrNull(): UUID? = try { null } +fun String.digits() = filter { it.isDigit() } + /** * @param threshold 0 = exact match */