Fix some issue

This commit is contained in:
mindfreq 2026-05-04 12:45:21 +02:00
parent 233c5aafed
commit 8a6336b70c
4 changed files with 9 additions and 12 deletions

View file

@ -45,9 +45,9 @@ pub async fn add_feed(url: &str) -> Result<Feed, Error> {
Feed::add(title, &feed.url, &feed.feed_url, icon) Feed::add(title, &feed.url, &feed.feed_url, icon)
} }
None => { None => {
return Err(Error::MissingField( Err(Error::MissingField(
"No RSS/Atom/JSON feed found at this URL".into(), "No RSS/Atom/JSON feed found at this URL".into(),
)); ))
} }
} }
} }
@ -60,7 +60,7 @@ pub async fn get_feeds() -> Result<Vec<Feed>, Error> {
#[tauri::command] #[tauri::command]
pub async fn remove_feed(website_url: &str) -> Result<Feed, Error> { pub async fn remove_feed(website_url: &str) -> Result<Feed, Error> {
Ok(Feed::remove(website_url)?) Feed::remove(website_url)
} }
// ======================================================= // =======================================================
@ -75,7 +75,7 @@ pub async fn get_feed_item(website_url: String) -> Result<Vec<FeedItem>, Error>
.await?; .await?;
FeedItem::from_feed(&xml) FeedItem::from_feed(&xml)
} else { } else {
return Err(Error::MissingField("no feed found in the settings.".into())); Err(Error::MissingField("no feed found in the settings.".into()))
} }
} }
@ -91,6 +91,6 @@ pub async fn get_entry(website_url: String, target_url: String) -> Result<FeedEn
FeedEntry::from_feed(&xml, &target_url) FeedEntry::from_feed(&xml, &target_url)
} else { } else {
return Err(Error::MissingField("no feed found in the settings.".into())); Err(Error::MissingField("no feed found in the settings.".into()))
} }
} }

View file

@ -92,7 +92,7 @@ pub mod feed_config {
fs::write(path, "[]")?; fs::write(path, "[]")?;
} }
let data = fs::read_to_string(&path)?; let data = fs::read_to_string(path)?;
Ok(serde_json::from_str(&data)?) Ok(serde_json::from_str(&data)?)
} }
} }

View file

@ -9,7 +9,7 @@ use commands::feed::{add_feed, get_entry, get_feed_item, get_feeds, remove_feed}
pub fn run() { pub fn run() {
tauri::Builder::default() tauri::Builder::default()
.setup(|app| { .setup(|app| {
config::init_config_path(&app.handle())?; config::init_config_path(app.handle())?;
Ok(()) Ok(())
}) })
.plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_opener::init())

View file

@ -184,11 +184,8 @@ fn resolve_url(base: &str, href: &str) -> String {
format!("https:{}", href) format!("https:{}", href)
} else if href.starts_with('/') { } else if href.starts_with('/') {
// رابط مطلق نسبي // رابط مطلق نسبي
let base = if base.ends_with('/') { let base = base.strip_suffix('/').unwrap_or(base);
&base[..base.len() - 1]
} else {
base
};
format!("{}{}", base, href) format!("{}{}", base, href)
} else { } else {
// رابط نسبي // رابط نسبي