Merge pull request #870 from Arthur-Milchior/trim_start_field_name

Trim the start of field name if it is #, /, ^ or a whitespace
This commit is contained in:
Damien Elmes 2020-12-28 13:06:57 +10:00 committed by GitHub
commit b8a96d81f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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();
}