fix: 自动清理 domain 配置中的 Markdown 链接格式

- setConfigValue: 添加 URL 清理逻辑,移除 Markdown 链接格式和末尾斜杠
- handleConfigCommandV2: /config add 命令自动清理 domain 参数
- 防止用户从飞书卡片复制 URL 时带入 Markdown 格式

修复场景:
- 用户从卡片复制域名 [https://example.com](https://example.com/)
- 使用 /config set 命令设置 domain
- 自动清理为纯 URL: https://example.com
This commit is contained in:
编程专家
2026-03-25 11:12:52 +08:00
parent 1506c77a53
commit 45831ad586
2 changed files with 26 additions and 1 deletions

View File

@@ -76,6 +76,20 @@ class QiniuUploader {
const lastKey = keys[keys.length - 1];
// 清理 URL 中的 Markdown 格式(防止用户从卡片复制时带入)
if (typeof value === 'string' && (value.includes('http://') || value.includes('https://'))) {
// 移除 Markdown 链接格式:[text](url) → url
const markdownLinkRegex = /\[([^\]]+)\]\(([^)]+)\)/;
const match = value.match(markdownLinkRegex);
if (match) {
value = match[2]; // 提取 URL 部分
}
// 移除末尾的斜杠
if (value.endsWith('/')) {
value = value.slice(0, -1);
}
}
// 类型转换
if (value === 'true') value = true;
else if (value === 'false') value = false;