Files
DeepTutor/web/lib/chat-file-link.ts
Qiu 506cea9d4f feat(desktop): finish Windows chat file actions (#3051)
Continues #2978 and closes #2887. Includes the original Windows file actions, integrates the changes with dev, and adds an explicit default-app action.

Co-authored-by: Botong Wu <2048400180@qq.com>
2026-11-28 13:09:15 -03:00

16 lines
753 B
TypeScript

/** Same-origin routes that serve a file already referenced by a conversation. */
export function isChatFileLink(href: string): boolean {
if (!href.startsWith('/files/') || /[\\\r\n\t]/.test(href)) return false
const { pathname } = new URL(href, 'http://deeptutor.local')
return /^\/files\/(?:workspace-items\/ws_[a-f\d]{32}\/wsi_[a-f\d]{32}|(?:outputs|attachments)\/.+)$/.test(
pathname
)
}
/** Published lesson pages render model-written scripts in the lesson sandbox. */
export function isChatVideoLessonLink(href: string): boolean {
if (!isChatFileLink(href)) return false
const { pathname } = new URL(href, 'http://deeptutor.local')
return /^\/files\/outputs\/(?:[^/]+\/)*video_lesson\/(?:[^/]+\/)*[^/]+\.html$/.test(pathname)
}