mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
fix: allow emojis for location markers
is_marker() should check for length in characters,
not bytes.
This was broken during the Rust translation
in changeset a5553f98af
This commit is contained in:
@@ -372,7 +372,12 @@ pub async fn get_range(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_marker(txt: &str) -> bool {
|
fn is_marker(txt: &str) -> bool {
|
||||||
txt.len() == 1 && !txt.starts_with(' ')
|
let mut chars = txt.chars();
|
||||||
|
if let Some(c) = chars.next() {
|
||||||
|
!c.is_whitespace() && chars.next().is_none()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes all locations from the database.
|
/// Deletes all locations from the database.
|
||||||
@@ -777,4 +782,13 @@ mod tests {
|
|||||||
assert!(locations_ref[0].accuracy.abs() < f64::EPSILON);
|
assert!(locations_ref[0].accuracy.abs() < f64::EPSILON);
|
||||||
assert_eq!(locations_ref[0].timestamp, timestamp);
|
assert_eq!(locations_ref[0].timestamp, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_is_marker() {
|
||||||
|
assert!(is_marker("f"));
|
||||||
|
assert!(!is_marker("foo"));
|
||||||
|
assert!(is_marker("🏠"));
|
||||||
|
assert!(!is_marker(" "));
|
||||||
|
assert!(!is_marker("\t"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user