From 546cb622d37285ec1ccc57eab6a40ac834ae9bab Mon Sep 17 00:00:00 2001 From: Rabindra Dhakal Date: Wed, 13 Nov 2024 20:17:48 +0545 Subject: [PATCH] fix(download): fix github regex pattern and make filter case-insensitive --- src/misc/download.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/misc/download.rs b/src/misc/download.rs index a5cbfeb..838882f 100644 --- a/src/misc/download.rs +++ b/src/misc/download.rs @@ -40,7 +40,7 @@ struct GithubRelease { } static GITHUB_URL_REGEX: &str = - r"^(?i)(?:https?://)?(?:github(?:\.com)?[:/])([^/@]+/[^/@]+)(?:@([^/\s]+))?(?:/.*)?$"; + r"^(?i)(?:https?://)?(?:github(?:\.com)?[:/])([^/@]+/[^/@]+)(?:@([^/\s]+))?$"; fn extract_filename(url: &str) -> String { Path::new(url) @@ -259,10 +259,14 @@ pub async fn download_and_save( .iter() .all(|regex| regex.is_match(&asset.name)) && match_keywords.map_or(true, |keywords| { - keywords.iter().all(|keyword| asset.name.contains(keyword)) + keywords.iter().all(|keyword| { + asset.name.to_lowercase().contains(&keyword.to_lowercase()) + }) }) && exclude_keywords.map_or(true, |keywords| { - keywords.iter().all(|keyword| !asset.name.contains(keyword)) + keywords.iter().all(|keyword| { + !asset.name.to_lowercase().contains(&keyword.to_lowercase()) + }) }) }) .collect();