From 66ab3cc0862448d3becacfbc1ffac5b2d5e500fa Mon Sep 17 00:00:00 2001 From: Jean Mertz Date: Tue, 3 Feb 2026 13:06:55 +0100 Subject: [PATCH] enhance(attachment_bear_note): support Bear "Copy Link" URI format The `jp` tool now supports Bear note links in the official x-callback-url format. This allows users to paste links generated via Bear's "Copy Link" feature directly into their conversations. Previously, only the simplified `bear://get/` and `bear://search/` URI formats were supported. The parser now correctly handles URIs like: `bear://x-callback-url/open-note?id=E340A2C4-8671-4233-860B-6AEFF7CB00D8` Signed-off-by: Jean Mertz --- crates/jp_attachment_bear_note/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/jp_attachment_bear_note/src/lib.rs b/crates/jp_attachment_bear_note/src/lib.rs index 5a4a645..959e326 100644 --- a/crates/jp_attachment_bear_note/src/lib.rs +++ b/crates/jp_attachment_bear_note/src/lib.rs @@ -162,6 +162,13 @@ fn uri_to_query(uri: &Url) -> Result> { .collect::, _>>()?; let query = match uri.host_str() { + // Support official "Copy Link" x-callback-url links: + // bear://x-callback-url/open-note?id=E340A2C4-8671-4233-860B-6AEFF7CB00D8 + Some("x-callback-url") if path == "open-note" => query_pairs + .into_iter() + .find_map(|(k, v)| (k == "id").then_some(v)) + .ok_or("Missing note id") + .map(Query::Get)?, Some("get") => Query::Get(path), Some("search") => { let tags = query_pairs @@ -309,6 +316,10 @@ mod tests { #[test] fn test_uri_to_query() { let cases = [ + ( + "bear://x-callback-url/open-note?id=123-456", + Ok(Query::Get("123-456".to_string())), + ), ("bear://get/1", Ok(Query::Get("1".to_string()))), ( "bear://get/tag%20%231",