fix: add validation for profile URL format during import

This commit is contained in:
Tunglies
2025-06-23 23:30:33 +08:00
Unverified
parent 6d519dac1e
commit 0a8d6e5147
5 changed files with 12 additions and 6 deletions

View File

@@ -7,6 +7,7 @@
- 修复在轻量模式下快速点击托盘图标带来的竞争态卡死问题
- 修复同时开启静默启动与自动进入轻量模式后,自动进入轻量模式失效的问题
- 修复静默启动时托盘工具栏轻量模式开启与关闭状态的同步
- 修复导入订阅时非 http 协议链接被错误尝试导入
### ✨ 新增功能

View File

@@ -623,5 +623,6 @@
"Originals Only": "Originals Only",
"No (IP Banned By Disney+)": "No (IP Banned By Disney+)",
"Unsupported Country/Region": "Unsupported Country/Region",
"Failed (Network Connection)": "Failed (Network Connection)"
"Failed (Network Connection)": "Failed (Network Connection)",
"Invalid Profile URL": "Invalid profile URL. Please enter a URL starting with http:// or https://"
}

View File

@@ -581,5 +581,6 @@
"Originals Only": "Только Originals",
"No (IP Banned By Disney+)": "Нет (IP забанен Disney+)",
"Unsupported Country/Region": "Страна/регион не поддерживается",
"Failed (Network Connection)": "Ошибка подключения"
"Failed (Network Connection)": "Ошибка подключения",
"Invalid Profile URL": "Недопустимая ссылка на профиль, введите адрес, начинающийся с http:// или https://"
}

View File

@@ -623,5 +623,6 @@
"Originals Only": "仅限原创",
"No (IP Banned By Disney+)": "不支持IP被Disney+禁止)",
"Unsupported Country/Region": "不支持的国家/地区",
"Failed (Network Connection)": "测试失败(网络连接问题)"
"Failed (Network Connection)": "测试失败(网络连接问题)",
"Invalid Profile URL": "无效的订阅链接,请输入以 http:// 或 https:// 开头的地址"
}

View File

@@ -227,8 +227,12 @@ const ProfilePage = () => {
const onImport = async () => {
if (!url) return;
// 校验url是否为http/https
if (!/^https?:\/\//i.test(url)) {
showNotice("error", t("Invalid Profile URL"));
return;
}
setLoading(true);
try {
// 尝试正常导入
await importProfile(url);
@@ -240,14 +244,12 @@ const ProfilePage = () => {
// 首次导入失败,尝试使用自身代理
const errmsg = err.message || err.toString();
showNotice("info", t("Import failed, retrying with Clash proxy..."));
try {
// 使用自身代理尝试导入
await importProfile(url, {
with_proxy: false,
self_proxy: true,
});
// 回退导入成功
showNotice("success", t("Profile Imported with Clash proxy"));
setUrl("");