Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/jp_attachment_bear_note/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ fn uri_to_query(uri: &Url) -> Result<Query, Box<dyn Error + Send + Sync>> {
.collect::<Result<Vec<_>, _>>()?;

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
Expand Down Expand Up @@ -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",
Expand Down
Loading