Trim the start of field name if it is #, /, ^ or a whitespace

I actually need to trim whitespace again to deal with a field name of the form "# foo"
This commit is contained in:
Arthur Milchior 2020-12-28 03:32:05 +01:00
parent ebc77985d8
commit 01caa3d996

View file

@ -42,7 +42,8 @@ impl NoteField {
self.name = self.name.replace(bad_chars, "");
}
// and leading/trailing whitespace
let trimmed = self.name.trim();
let bad_start_chars = |c: char| c == '#' || c == '/' || c == '^' || c.is_whitespace();
let trimmed = self.name.trim().trim_start_matches(bad_start_chars);
if trimmed.len() != self.name.len() {
self.name = trimmed.into();
}