Use a less restrictive regex for unit converter parsing

This commit is contained in:
MM20 2022-02-19 16:15:53 +01:00
parent ff5281d360
commit 3c3cfc7120
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389

View File

@ -36,7 +36,7 @@ internal class UnitConverterRepositoryImpl(val context: Context) : UnitConverter
}
private suspend fun queryUnitConverter(query: String): UnitConverter? {
if (!query.matches(Regex("[0-9,.:]+ [A-Za-z/²³°.]+")) && !query.matches(Regex("[0-9,.:]+ [A-Za-z/²³°.]+ >> [A-Za-z/²³°]+"))) return null
if (!query.matches(Regex("[0-9,.:]+ [^\\s]+")) && !query.matches(Regex("[0-9,.:]+ [^\\s]+ >> [^\\s]+"))) return null
val valueStr: String
val unitStr: String
val targetUnitStr: String?