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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user