Drop the last character for string length validation, bump version

This commit is contained in:
Garth Vander Houwen 2024-04-04 09:39:03 -07:00
parent 7acb6aad32
commit aa08f2ff33
11 changed files with 21 additions and 101 deletions

View file

@ -94,12 +94,7 @@ struct DetectionSensorConfig: View {
let totalBytes = name.utf8.count
// Only mess with the value if it is too big
if totalBytes > 20 {
let firstNBytes = Data(name.utf8.prefix(20))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
name = maxBytesString
}
name = String(name.dropLast())
}
})
}