Refactor: invert whitespace stripping pattern

This commit is contained in:
Toes | Robin Ury 2026-08-21 07:18:03 -04:00
parent 00ec796c7a
commit b1061f0165
No known key found for this signature in database
GPG key ID: A5DAA8C945CA3941

View file

@ -15,7 +15,7 @@ enum Kind { PLAYER, SYSTEM }
static func sanitize_body(value: Variant) -> String: static func sanitize_body(value: Variant) -> String:
if typeof(value) != TYPE_STRING: if typeof(value) != TYPE_STRING:
return "" return ""
var strippable_whitespace = RegEx.create_from_string("^[\\s\\p{Z}\\p{Cf}\\x{2800}]+|[\\s\\p{Z}\\p{Cf}\\x{2800}]+$") var strippable_whitespace = RegEx.create_from_string("^[^\\w]+|[^\\w]+$")
var result := strippable_whitespace.sub(value, "") var result := strippable_whitespace.sub(value, "")
if result.is_empty() or result.length() > MAX_VISIBLE_CHARACTERS: if result.is_empty() or result.length() > MAX_VISIBLE_CHARACTERS:
return "" return ""