Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(core): street names, map links and spaced codes are recognised
Bee790b3acc4661
diff --git a/core/nectarlink-core/src/clip_kind.rs b/core/nectarlink-core/src/clip_kind.rsindex b523321..81468b9 100644--- a/core/nectarlink-core/src/clip_kind.rs+++ b/core/nectarlink-core/src/clip_kind.rs@@ -498,6 +498,7 @@ fn detect_phone_number(s: &str) -> Option<String> {}/// Street/road designator words across English, French, German, Spanish, Italian, and Indian addresses.+/// Sorted: looked up with `binary_search`.const STREET_DESIGNATORS: &[&str] = &["allee","allée",@@ -515,8 +516,8 @@ const STREET_DESIGNATORS: &[&str] = &["close","colony","corso",- "court","cours",+ "court","cres","crescent","ct",@@ -827,6 +828,11 @@ fn has_postal_code(s: &str) -> bool {mod tests {use super::*;+ #[test]+ fn street_designators_are_sorted_for_binary_search() {+ assert!(STREET_DESIGNATORS.windows(2).all(|w| w[0] < w[1]));+ }+#[test]fn web_links_vs_file_paths_and_text() {let positives = [diff --git a/core/nectarlink-core/src/handoff.rs b/core/nectarlink-core/src/handoff.rsindex a7b20bd..c3cc4b6 100644--- a/core/nectarlink-core/src/handoff.rs+++ b/core/nectarlink-core/src/handoff.rs@@ -174,7 +174,8 @@ pub fn with_video_timestamp(url: &str, secs: u32) -> String {/// platforms without a registered `geo:` handler can open it in the browser.#[must_use]pub fn geo_to_maps_https(uri: &str) -> Option<String> {- let rest = uri.trim().strip_prefix("geo:").or_else(|| uri.trim().strip_prefix("GEO:"))?;+ let uri = uri.trim();+ let rest = uri.get(..4).filter(|scheme| scheme.eq_ignore_ascii_case("geo:")).map(|_| &uri[4..])?;let (coords_part, query_part) = match rest.split_once('?') {Some((c, q)) => (c, Some(q)),None => (rest, None),@@ -597,6 +598,11 @@ mod tests {geo_to_maps_https(&geo.url).as_deref(),Some("https://www.google.com/maps/search/?api=1&query=Golden+Gate+Bridge"));+ assert_eq!(+ geo_to_maps_https("Geo:37.7749,-122.4194?q=Golden+Gate+Bridge"),+ geo_to_maps_https(&geo.url),+ "the scheme in any case"+ );let coords_only = extract_handoff_link("geo:48.8584,2.2945").unwrap();assert_eq!(coords_only.kind, HandoffKind::MapLocation);diff --git a/core/nectarlink-core/src/otp.rs b/core/nectarlink-core/src/otp.rsindex 66e434c..a6466a0 100644--- a/core/nectarlink-core/src/otp.rs+++ b/core/nectarlink-core/src/otp.rs@@ -53,11 +53,18 @@ pub fn is_otp_clip(text: &str) -> bool {}/// Whether `trimmed` is nothing but a standalone 4-8 digit code, `"G-123456"`,-/// `"123-456"` or `"1234-5678"`.+/// `"123-456"`, `"1234-5678"`, or the same groups split by a space.pub fn is_bare_code(trimmed: &str) -> bool {if (4..=8).contains(&trimmed.len()) && trimmed.bytes().all(|b| b.is_ascii_digit()) {return true;}+ if let Some((first, second)) = trimmed.split_once(' ')+ && (first.len() == 3 || first.len() == 4)+ && second.len() == first.len()+ && first.bytes().chain(second.bytes()).all(|b| b.is_ascii_digit())+ {+ return true;+ }if let Some((prefix, rest)) = trimmed.split_once('-') {if (1..=3).contains(&prefix.len())&& prefix.bytes().all(|b| b.is_ascii_alphabetic())@@ -687,6 +694,16 @@ fn preceding_clause_words(lower_chars: &[char], pos: usize, max_words: usize) ->mod tests {use super::*;+ #[test]+ fn grouped_codes_are_bare_codes_with_a_dash_or_a_space() {+ for code in ["482913", "G-482913", "123-456", "1234-5678", "123 456", "1234 5678"] {+ assert!(is_bare_code(code), "{code}");+ }+ for text in ["123 4567", "12 34", "123 456", "abc 123", "2026-10-10"] {+ assert!(!is_bare_code(text), "{text}");+ }+ }+#[test]fn detects_real_world_positive_examples() {let cases: &[(&str, &str)] = &[diff --git a/core/nectarlink-core/src/timeline.rs b/core/nectarlink-core/src/timeline.rsindex 8023169..d2e04e8 100644--- a/core/nectarlink-core/src/timeline.rs+++ b/core/nectarlink-core/src/timeline.rs@@ -209,7 +209,8 @@ pub fn format_clip_display(raw_text: &str) -> (String, Option<String>) {.unwrap_or(first_line).trim();- let lower_prefix = unquoted.get(..8).map(str::to_ascii_lowercase).unwrap_or_default();+ // Up to 8 characters: `geo:0,0` is shorter than that.+ let lower_prefix: String = unquoted.chars().take(8).collect::<String>().to_ascii_lowercase();if (lower_prefix.starts_with("http://")|| lower_prefix.starts_with("https://")|| lower_prefix.starts_with("geo:"))@@ -359,6 +360,8 @@ mod tests {assert_eq!(t2, "Link · example.com");assert_eq!(d2.as_deref(), Some("https://example.com/posts/12345"));+ let (geo_title, geo_raw) = format_clip_display("geo:0,0");+ assert_eq!(geo_raw.as_deref(), Some("geo:0,0"), "a short map link is still a link: {geo_title}");let (t3, d3) = format_clip_display("Short note");assert_eq!(t3, "Short note");assert_eq!(d3, None);