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

@ -53,11 +53,7 @@ struct WaypointFormMapKit: View {
let totalBytes = name.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(name.utf8.prefix(30))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
name = maxBytesString
}
name = String(name.dropLast())
}
})
}
@ -74,11 +70,7 @@ struct WaypointFormMapKit: View {
let totalBytes = description.utf8.count
// Only mess with the value if it is too big
if totalBytes > 100 {
let firstNBytes = Data(description.utf8.prefix(100))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the name back to the last place where it was the right size
description = maxBytesString
}
description = String(description.dropLast())
}
})
}