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 — trailing IDN stop, extra punct, mobile ~
Chrisb7a4a6e88bec
diff --git a/apps/mobile/src/__tests__/messageMarkdown.test.ts b/apps/mobile/src/__tests__/messageMarkdown.test.tsindex 53ba083d76..09ca1995a4 100644--- a/apps/mobile/src/__tests__/messageMarkdown.test.ts+++ b/apps/mobile/src/__tests__/messageMarkdown.test.ts@@ -287,6 +287,24 @@ describe('messageMarkdown', () => {{ type: 'link', text: 'https://example.com/path', url: 'https://example.com/path' },{ type: 'text', text: ') 收尾' },]);+ expect(parseMobileMarkdownInlines('~https://example.com/~alice')).toEqual([+ { type: 'text', text: '~' },+ {+ type: 'link',+ text: 'https://example.com/~alice',+ url: 'https://example.com/~alice',+ },+ ]);+ expect(parseMobileMarkdownInlines('看 https://例子。测试。')).toEqual([+ { type: 'text', text: '看 ' },+ { type: 'link', text: 'https://例子。测试', url: 'https://例子。测试' },+ { type: 'text', text: '。' },+ ]);+ expect(parseMobileMarkdownInlines('看 https://example.com/path・说明')).toEqual([+ { type: 'text', text: '看 ' },+ { type: 'link', text: 'https://example.com/path', url: 'https://example.com/path' },+ { type: 'text', text: '・说明' },+ ]);expect(parseMobileMarkdownInlines('看 http://localhost:3000。然后')).toEqual([{ type: 'text', text: '看 ' },{ type: 'link', text: 'http://localhost:3000', url: 'http://localhost:3000' },diff --git a/apps/mobile/src/session/messageMarkdown.ts b/apps/mobile/src/session/messageMarkdown.tsindex 533cbf4de8..d9b20e0239 100644--- a/apps/mobile/src/session/messageMarkdown.ts+++ b/apps/mobile/src/session/messageMarkdown.ts@@ -2,6 +2,7 @@ import { normalizeMathDelimiters } from '@cindy/maker-shared/math-markdown';import {BARE_HTTP_URL_RE_SOURCE,clipBareHttpAutolinkText,+ markdownWrapMarkerFromPrefix,} from '@cindy/maker-shared/url-text-boundary';import {classifyChatPathLinkTarget,@@ -808,6 +809,12 @@ export function parseMobileMarkdownInlines(return out.length > 0 ? out : [{ type: 'text', text: input }];}+/** Mobile 只把 `~~` 当删除线,单个 `~` 是普通字符,不能当 URL 包裹标记。 */+function mobileMarkdownWrapMarker(prefix: string): string | null {+ const marker = markdownWrapMarkerFromPrefix(prefix);+ return marker === '~' ? null : marker;+}+function findNextInlineToken(input: string,from: number,@@ -890,7 +897,12 @@ function findNextInlineToken((match) => {const rawHref = match[0];const href = /^https?:\/\//i.test(rawHref)- ? clipBareHttpAutolinkText(rawHref, { prefix: input.slice(0, match.index) })+ ? clipBareHttpAutolinkText(rawHref, {+ prefix: input.slice(0, match.index),+ markdownWrapMarker: mobileMarkdownWrapMarker(+ input.slice(0, match.index),+ ),+ }): trimUrlPunctuation(rawHref);return { type: 'link' as const, text: href, url: href };},diff --git a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts b/packages/maker-shared/src/__tests__/urlTextBoundary.test.tsindex c59fc5b049..4d894bf92e 100644--- a/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts+++ b/packages/maker-shared/src/__tests__/urlTextBoundary.test.ts@@ -94,6 +94,15 @@ describe('clipBareHttpAutolinkText', () => {expect(clipBareHttpAutolinkText('https://例子。测试:443/path')).toBe('https://例子。测试:443/path',);+ expect(clipBareHttpAutolinkText('https://例子。测试。')).toBe(+ 'https://例子。测试',+ );+ expect(clipBareHttpAutolinkText('https://example.com/path・说明')).toBe(+ 'https://example.com/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.tsindex 9f1eec9ba9..b4d184b621 100644--- a/packages/maker-shared/src/urlTextBoundary.ts+++ b/packages/maker-shared/src/urlTextBoundary.ts@@ -347,21 +347,16 @@ export function shrinkAutolinkTrailingJunk(* authority 决定。半角括号留给 `clipBareHttpAutolink` 按配对处理。*/export const BARE_HTTP_URL_RE_SOURCE =- String.raw`https?://[^\s<>"\u2018-\u201F\u2026\u3000-\u3001\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\uFF01-\uFF0D\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF60\uFF62-\uFF65]+`;+ String.raw`https?://[^\s<>"\u2013-\u2015\u2018-\u201F\u2022\u2026\u3000-\u3001\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30FB\uFE10-\uFE19\uFF01-\uFF0D\uFF0F\uFF1A-\uFF20\uFF3B-\uFF40\uFF5B-\uFF60\uFF62-\uFF65]+`;const MARKDOWN_FORMATTING_STRIP_BOUNDARY =/[\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF]/;-const CJK_OR_FULLWIDTH_PUNCT_BLOCK =- /(?:[\u3000-\u303F\uFF00-\uFFEF])/u;-function isAutolinkPunctuationBoundary(ch: string): boolean {const code = ch.codePointAt(0);if (code == null) return false;if (ch === '"' || ch === '`') return true;- if (code >= 0x2018 && code <= 0x201f) return true;- if (code === 0x2026) return true;- if (!CJK_OR_FULLWIDTH_PUNCT_BLOCK.test(ch)) return false;+ if (code < 0x80) return false;return /^\p{P}$/u.test(ch) || /^\p{Z}$/u.test(ch);}@@ -396,8 +391,18 @@ function hostnameEndIndex(raw: string): number {return authEnd;}+function isHostLabelChar(ch: string | undefined): boolean {+ if (ch == null || isIdnDomainDot(ch)) return false;+ if (ch === '/' || ch === '?' || ch === '#' || ch === ':' || ch === '@') return false;+ return !isAutolinkPunctuationBoundary(ch);+}+function isIdnDotInHostname(raw: string, index: number, hostnameEnd: number): boolean {- return index < hostnameEnd && isIdnDomainDot(raw[index] ?? '');+ return (+ index < hostnameEnd &&+ isIdnDomainDot(raw[index] ?? '') &&+ isHostLabelChar(raw[index + 1])+ );}/**