validate url backgrounds

This commit is contained in:
SpikeHD
2022-06-01 19:20:43 -07:00
parent fe48eb3c67
commit e71ca9ff40
3 changed files with 21 additions and 3 deletions

View File

@@ -57,7 +57,8 @@ fn main() {
downloader::download_file,
downloader::stop_download,
lang::get_lang,
lang::get_languages
lang::get_languages,
web::valid_url
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View File

@@ -5,4 +5,14 @@ pub(crate) async fn query(site: &str) -> String {
let response = client.get(site).header(USER_AGENT, "cultivation").send().await.unwrap();
return response.text().await.unwrap();
}
#[tauri::command]
pub(crate) async fn valid_url(url: String) -> bool {
// Check if we get a 200 response
let client = reqwest::Client::new();
let response = client.get(url).header(USER_AGENT, "cultivation").send().await.unwrap();
return response.status().as_str() == "200";
}