Added the use of the file protocol to have a local hyperlink when confronted with a non HTTPS URI.

Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com>
This commit is contained in:
alexis-opolka 2025-05-11 18:17:55 +02:00
parent 122f06ed9c
commit 79ab8525f2

View file

@ -2,7 +2,7 @@ use crate::filesystem::local_cheatsheet_repositories;
use crate::libs::terminal::hyperlink;
pub fn main() {
let (cheats_repos, _) = local_cheatsheet_repositories();
let (cheats_repos, cheats_paths) = local_cheatsheet_repositories();
// Now that we have our list of cheatsheet repositories, we loop through them
// Two behaviours:
@ -19,6 +19,7 @@ pub fn main() {
// The list shouldn't be empty
eprintln!("You have locally available the following cheatsheet repositories: \n");
let mut i: usize = 0;
for cheat_repo in cheats_repos {
let content = if cheat_repo.starts_with("https://") {
// If the URL is using the HTTPS scheme, we use a hyperlink
@ -26,9 +27,10 @@ pub fn main() {
hyperlink::new(&cheat_repo, &cheat_repo)
} else {
cheat_repo.to_owned()
hyperlink::new(&format!("file://{}", &cheats_paths[i]), &cheat_repo)
};
eprintln!("- {}", content);
i += 1;
}
}