Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix: address review — CJK IDN length only when host is bare

Chris3f83fda0c5a7
diff --git a/apps/mobile/src/__tests__/messageMarkdown.test.ts b/apps/mobile/src/__tests__/messageMarkdown.test.ts
index 82c953856e..0ca1f34716 100644
--- a/apps/mobile/src/__tests__/messageMarkdown.test.ts
+++ b/apps/mobile/src/__tests__/messageMarkdown.test.ts
@@ -323,6 +323,15 @@ describe('messageMarkdown', () => {
{ type: 'link', text: 'https://例子。测试', url: 'https://例子。测试' },
{ type: 'text', text: '。这是说明' },
]);
+ expect(parseMobileMarkdownInlines('打开 https://例子。ファッション/path 看')).toEqual([
+ { type: 'text', text: '打开 ' },
+ {
+ type: 'link',
+ text: 'https://例子。ファッション/path',
+ url: 'https://例子。ファッション/path',
+ },
+ { type: 'text', text: ' 看' },
+ ]);
expect(parseMobileMarkdownInlines('看 https://example.com。这是说明')).toEqual([
{ type: 'text', text: '看 ' },
{ type: 'link', text: 'https://example.com', url: 'https://example.com' },
diff --git a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts b/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts
index 00e49e9ec6..20a8efef56 100644
--- a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts
+++ b/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts
@@ -115,6 +115,9 @@ describe('clipBareHttpAutolinkText', () => {
expect(clipBareHttpAutolinkText('https://example.com。这是说明')).toBe(
'https://example.com',
);
+ expect(clipBareHttpAutolinkText('https://例子。ファッション/path')).toBe(
+ 'https://例子。ファッション/path',
+ );
expect(clipBareHttpAutolinkText('https://example.com/path・说明')).toBe(
'https://example.com/path',
);
diff --git a/packages/maker-shared/src/urlTextBoundary.ts b/packages/maker-shared/src/urlTextBoundary.ts
index a0b31c3b81..7e442db029 100644
--- a/packages/maker-shared/src/urlTextBoundary.ts
+++ b/packages/maker-shared/src/urlTextBoundary.ts
@@ -428,10 +428,10 @@ function isIdnDotInHostname(
// 俄文/拉丁等字母脚本是真 IDN 标签,不限长度。
if (chars.some((ch) => /^\p{L}$/u.test(ch) && !isCjkLetter(ch))) return true;
if (chars.some((ch) => /[A-Za-z0-9]/.test(ch))) return true;
- // 纯汉字标签:后面还有域名分隔符说明主机还没完(`四字域名。测试`);
- // 否则只留 1–3 字的 TLD 形标签,避免 `。这是说明` 并进主机名。
+ // 纯汉字标签:后面还有域名分隔符,或已有 path/port/query,说明主机还没完。
+ // 无路径的歧义场景才用 1–3 字 TLD 上限,避免 `。这是说明` 并进主机名。
const after = raw[labelEnd];
- if (after === '.' || isIdnDomainDot(after)) return true;
+ if (after === '.' || isIdnDomainDot(after) || hostEnd < raw.length) return true;
return chars.length <= 3;
}