Skip to content

Commit

Permalink
feat: add deeplinks for search history item
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Dec 10, 2023
1 parent 261af86 commit e5c5a69
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,20 @@ impl From<(&String, &LibraryRequest)> for LibraryDeepLinks {
}
}
}

#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SearchHistoryItemDeepLinks {
pub search: String,
}

impl From<&String> for SearchHistoryItemDeepLinks {
fn from(query: &String) -> Self {
SearchHistoryItemDeepLinks {
search: format!(
"stremio:///search?query={}",
utf8_percent_encode(query, URI_COMPONENT_ENCODE_SET),
),
}
}
}
1 change: 1 addition & 0 deletions src/unit_tests/deep_links/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ mod external_player_link;
mod library_deep_links;
mod library_item_deep_links;
mod meta_item_deep_links;
mod search_history_item_deep_links;
mod stream_deep_links;
mod video_deep_links;
11 changes: 11 additions & 0 deletions src/unit_tests/deep_links/search_history_item_deep_links.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use crate::deep_links::SearchHistoryItemDeepLinks;

#[test]
fn search_history_item_deep_links() {
let query = "better call saul".to_string();
let deep_link = SearchHistoryItemDeepLinks::from(&query);
assert_eq!(
deep_link.search,
"stremio:///search?query=better%20call%20saul".to_string(),
);
}

0 comments on commit e5c5a69

Please sign in to comment.