mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:50:36 +08:00
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>
16 lines
753 B
TypeScript
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)
|
|
}
|