mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
fix(artifact): scanner type narrowing and url regex
- Use double assertion (`as unknown as Record<string, unknown>`) at lines 30 and 90 to fix TS2352 per project convention - Tighten URL_REGEX to avoid capturing trailing punctuation (parens, quotes, commas) when URL is embedded in text - Add test case for array-form tool_result content path Co-Authored-By: glm-5.2 <zai-org@claude-code-best.win>
This commit is contained in:
@@ -12,7 +12,7 @@ export type ArtifactInfo = {
|
||||
isError: boolean
|
||||
}
|
||||
|
||||
const URL_REGEX = /https?:\/\/\S+\.html\b/
|
||||
const URL_REGEX = /https?:\/\/[^\s)"',]+\.html\b/
|
||||
const ID_REGEX = /\bid:\s*([A-Za-z0-9_-]+)/
|
||||
const EXPIRES_REGEX = /\bexpires:\s*([0-9T:.Z+-]+)/
|
||||
|
||||
@@ -27,7 +27,7 @@ export function extractArtifacts(messages: Message[]): ArtifactInfo[] {
|
||||
for (const block of content) {
|
||||
if (typeof block !== 'object' || block === null) continue
|
||||
if (!('type' in block)) continue
|
||||
const b = block as Record<string, unknown>
|
||||
const b = block as unknown as Record<string, unknown>
|
||||
if (b.type !== 'tool_use') continue
|
||||
if (b.name !== 'artifact') continue
|
||||
|
||||
@@ -87,7 +87,7 @@ function findToolResult(
|
||||
for (const block of content) {
|
||||
if (typeof block !== 'object' || block === null) continue
|
||||
if (!('type' in block)) continue
|
||||
const b = block as Record<string, unknown>
|
||||
const b = block as unknown as Record<string, unknown>
|
||||
if (b.type !== 'tool_result') continue
|
||||
if (b.tool_use_id !== toolUseId) continue
|
||||
return { content: b.content, is_error: b.is_error as boolean | undefined }
|
||||
|
||||
Reference in New Issue
Block a user