chore: test deploy snapshot
This commit is contained in:
@@ -14,7 +14,7 @@ test('extractChatMessageParts normalizes absolute legacy dot-codex prompt previe
|
||||
assert.ok(prompt);
|
||||
assert.equal(
|
||||
prompt.options[0]?.preview?.url,
|
||||
'/api/chat/resources/chat-room/resource/source/chat-room-reference.md',
|
||||
'/api/chat/resources/.codex_chat/chat-room/resource/source/chat-room-reference.md',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ test('parseChatMessageParts normalizes absolute legacy link card urls to api cha
|
||||
{
|
||||
type: 'link_card',
|
||||
title: 'legacy resource',
|
||||
url: '/api/chat/resources/chat-room/resource/uploads/spec.png',
|
||||
url: '/api/chat/resources/.codex_chat/chat-room/resource/uploads/spec.png',
|
||||
actionLabel: '열기',
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -90,6 +90,20 @@ const CHAT_PUBLIC_DOT_CODEX_MARKER = '/public/.codex_chat/';
|
||||
const RESOURCE_MANAGER_PREVIEW_MARKER = '/api/resource-manager/preview/';
|
||||
const RESOURCE_MANAGER_ROOT_MARKER = 'resource/';
|
||||
|
||||
function buildCanonicalChatApiResourcePath(relativePath: string) {
|
||||
const normalizedRelativePath = normalizeText(relativePath).replace(/^\/+/, '');
|
||||
|
||||
if (!normalizedRelativePath) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (normalizedRelativePath.startsWith('.codex_chat/')) {
|
||||
return `${CHAT_API_RESOURCE_MARKER}${normalizedRelativePath}`;
|
||||
}
|
||||
|
||||
return `${CHAT_API_RESOURCE_MARKER}.codex_chat/${normalizedRelativePath}`;
|
||||
}
|
||||
|
||||
function normalizeText(value: unknown) {
|
||||
return String(value ?? '').trim();
|
||||
}
|
||||
@@ -239,11 +253,11 @@ function normalizeUrl(value: string) {
|
||||
}
|
||||
|
||||
if (pathname.startsWith(CHAT_PUBLIC_DOT_CODEX_MARKER)) {
|
||||
return `${CHAT_API_RESOURCE_MARKER}${pathname.slice(CHAT_PUBLIC_DOT_CODEX_MARKER.length)}`;
|
||||
return buildCanonicalChatApiResourcePath(pathname.slice(CHAT_PUBLIC_DOT_CODEX_MARKER.length));
|
||||
}
|
||||
|
||||
if (pathname.startsWith(CHAT_DOT_CODEX_MARKER)) {
|
||||
return `${CHAT_API_RESOURCE_MARKER}${pathname.slice(CHAT_DOT_CODEX_MARKER.length)}`;
|
||||
return buildCanonicalChatApiResourcePath(pathname.slice(CHAT_DOT_CODEX_MARKER.length));
|
||||
}
|
||||
} catch {
|
||||
// Fall through to handle relative and embedded resource paths below.
|
||||
@@ -259,18 +273,18 @@ function normalizeUrl(value: string) {
|
||||
const apiPath = normalized.slice(apiMarkerIndex);
|
||||
const dotCodexIndex = apiPath.indexOf(CHAT_DOT_CODEX_MARKER);
|
||||
return dotCodexIndex >= 0
|
||||
? `${CHAT_API_RESOURCE_MARKER}${apiPath.slice(dotCodexIndex + 1)}`
|
||||
? buildCanonicalChatApiResourcePath(apiPath.slice(dotCodexIndex + 1))
|
||||
: apiPath;
|
||||
}
|
||||
|
||||
const publicDotCodexIndex = normalized.lastIndexOf(CHAT_PUBLIC_DOT_CODEX_MARKER);
|
||||
if (publicDotCodexIndex >= 0) {
|
||||
return `${CHAT_API_RESOURCE_MARKER}${normalized.slice(publicDotCodexIndex + 8)}`;
|
||||
return buildCanonicalChatApiResourcePath(normalized.slice(publicDotCodexIndex + 8));
|
||||
}
|
||||
|
||||
const dotCodexIndex = normalized.lastIndexOf(CHAT_DOT_CODEX_MARKER);
|
||||
if (dotCodexIndex >= 0) {
|
||||
return `${CHAT_API_RESOURCE_MARKER}${normalized.slice(dotCodexIndex + 1)}`;
|
||||
return buildCanonicalChatApiResourcePath(normalized.slice(dotCodexIndex + 1));
|
||||
}
|
||||
|
||||
if (normalized === 'resource' || normalized === '/resource' || normalized.startsWith('resource/') || normalized.includes('/resource/')) {
|
||||
|
||||
Reference in New Issue
Block a user