Skip to content

Commit a5af654

Browse files
authored
Merge pull request #4 from rajaryan9358/language-additions
Crash fix
2 parents 9a46726 + 92e3bcb commit a5af654

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
Binary file not shown.

Sourcecode/.gradle/file-system.probe

0 Bytes
Binary file not shown.

Sourcecode/app/src/main/java/com/anthroteacher/multihasher/MainActivity.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,13 @@ fun sha64(input: String): String {
510510
}
511511

512512
fun validateAndParseInput(input: String, maxValue: Int): Int {
513+
if (input.isEmpty()) {
514+
return 1
515+
}
513516
val normalizedInput = input.trim().toUpperCase(Locale.ROOT)
514517
val value = when {
515-
normalizedInput.endsWith("K") -> (normalizedInput.dropLast(1).toDouble() * 1000).toInt()
516-
normalizedInput.endsWith("M") -> (normalizedInput.dropLast(1).toDouble() * 1000000).toInt()
518+
normalizedInput.endsWith("K") && normalizedInput.dropLast(1).isNotEmpty() -> (normalizedInput.dropLast(1).toDouble() * 1000).toInt()
519+
normalizedInput.endsWith("M") && normalizedInput.dropLast(1).isNotEmpty() -> (normalizedInput.dropLast(1).toDouble() * 1000000).toInt()
517520
else -> input.toIntOrNull() ?: 1
518521
}
519522
return value.coerceAtMost(maxValue)

0 commit comments

Comments
 (0)