Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix: address review — drop IDN label length cap
Chris4f01f4a04e4f
diff --git a/apps/mobile/src/__tests__/messageMarkdown.test.ts b/apps/mobile/src/__tests__/messageMarkdown.test.tsindex b71f740844..b1b285699f 100644--- a/apps/mobile/src/__tests__/messageMarkdown.test.ts+++ b/apps/mobile/src/__tests__/messageMarkdown.test.ts@@ -309,10 +309,23 @@ describe('messageMarkdown', () => {{ type: 'link', text: 'https://子域。例子。测试', url: 'https://子域。例子。测试' },{ type: 'text', text: ' 看' },]);- expect(parseMobileMarkdownInlines('看 https://例子。测试。这是说明')).toEqual([- { type: 'text', text: '看 ' },- { 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://子域。四字域名。测试 看')).toEqual([+ { type: 'text', text: '打开 ' },+ {+ type: 'link',+ text: 'https://子域。四字域名。测试',+ url: 'https://子域。四字域名。测试',+ },+ { type: 'text', text: ' 看' },]);expect(parseMobileMarkdownInlines('看 https://例子。测试。')).toEqual([{ type: 'text', text: '看 ' },diff --git a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts b/packages/maker-shared/src/__tests__/urlTextBoundary.test.tsindex cf5af3a4ee..f806915f39 100644--- a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts+++ b/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts@@ -97,15 +97,18 @@ describe('clipBareHttpAutolinkText', () => {expect(clipBareHttpAutolinkText('https://例子。测试。')).toBe('https://例子。测试',);- expect(clipBareHttpAutolinkText('https://例子。测试。这是说明')).toBe(- 'https://例子。测试',- );expect(clipBareHttpAutolinkText('https://子域。例子。测试')).toBe('https://子域。例子。测试',);expect(clipBareHttpAutolinkText('https://www。例子。测试')).toBe('https://www。例子。测试',);+ expect(clipBareHttpAutolinkText('https://пример。онлайн/path')).toBe(+ 'https://пример。онлайн/path',+ );+ expect(clipBareHttpAutolinkText('https://子域。四字域名。测试')).toBe(+ 'https://子域。四字域名。测试',+ );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.tsindex 3d2ea359d0..5086497cb7 100644--- a/packages/maker-shared/src/urlTextBoundary.ts+++ b/packages/maker-shared/src/urlTextBoundary.ts@@ -397,44 +397,23 @@ function isHostLabelChar(ch: string | undefined): boolean {return !isAutolinkPunctuationBoundary(ch);}-function nextHostLabelEnd(raw: string, from: number, hostEnd: number): number {- let index = from;- while (index < hostEnd) {- const code = raw.codePointAt(index);- if (code == null) break;- const char = String.fromCodePoint(code);- if (isIdnDomainDot(char) || char === '.') break;- if (!isHostLabelChar(char)) break;- index += char.length;- }- return index;-}--/** ASCII 标签或 1–3 个汉字/假名/谚文,当作域名标签;更长的 CJK 当正文。 */-function isLikelyIdnHostLabel(raw: string, from: number, to: number): boolean {- if (from >= to) return false;- const chars = [...raw.slice(from, to)];- if (chars.some((ch) => /[A-Za-z0-9]/.test(ch))) return true;- return chars.length <= 3 && chars.every((ch) => isHostLabelChar(ch));-}-function isIdnDotInHostname(raw: string,index: number,hostStart: number,hostEnd: number,): boolean {- if (index < hostStart || index >= hostEnd) return false;- if (!isIdnDomainDot(raw[index] ?? '') || !isHostLabelChar(raw[index + 1])) {- return false;- }- const labelEnd = nextHostLabelEnd(raw, index + 1, hostEnd);- return isLikelyIdnHostLabel(raw, index + 1, labelEnd);+ return (+ index >= hostStart &&+ index < hostEnd &&+ isIdnDomainDot(raw[index] ?? '') &&+ isHostLabelChar(raw[index + 1])+ );}/**- * 标点/全角符号是正文边界。hostname 里后面还像域名标签的 IDN 点号留下- * (`子域。例子。测试`);`。这是说明` 这种长 CJK 仍当句号。+ * 标点/全角符号是正文边界。hostname 里后面还跟标签的 IDN 点号一律留下+ * (`пример。онлайн`、`子域。四字域名。测试`)。句末单独的 `。` 仍切掉。*/function findAutolinkProseBoundary(raw: string): number {const { start: hostStart, end: hostEnd } = hostnameRange(raw);