fix(tauri): normalize external URLs by auto-prepending https:// when protocol is missing

This commit is contained in:
Jason
2025-08-24 23:35:07 +08:00
parent 1458f1e45d
commit f3f484a04b

View File

@@ -197,6 +197,12 @@ pub async fn open_config_folder() -> Result<bool, String> {
/// 打开外部链接
#[tauri::command]
pub async fn open_external(url: String) -> Result<bool, String> {
// 规范化 URL缺少协议时默认加 https://
let url = if url.starts_with("http://") || url.starts_with("https://") {
url
} else {
format!("https://{}", url)
};
#[cfg(target_os = "windows")]
{
std::process::Command::new("cmd")