This commit is contained in:
2026-10-18 03:11:10 +07:00
parent 8610f45a29
commit 3e2608eae3
23 changed files with 1460 additions and 302 deletions
+15 -9
View File
@@ -104,6 +104,20 @@ function mode(value: unknown): number {
return result
}
export function resolveMediaURL(server: string, value: string): string {
const ref = value.trim()
if (ref.startsWith('//') || (/^[a-z][a-z0-9+.-]*:/i.test(ref) && !/^https?:\/\//i.test(ref)))
throw new Error('Недопустимый адрес файла')
const url = httpURL(
/^https?:\/\//i.test(ref)
? ref
: ref.startsWith('/')
? new URL(ref, server).href
: `${server}/api/files/${encodeURIComponent(ref)}`,
).href
return url
}
// Только проекция данных показа: сырые ответы API могут содержать участников и секреты.
export function buildScreenPackage(
server: string,
@@ -122,15 +136,7 @@ export function buildScreenPackage(
function asset(value: unknown): string | null {
const ref = text(value).trim()
if (!ref) return null
if (ref.startsWith('//') || (/^[a-z][a-z0-9+.-]*:/i.test(ref) && !/^https?:\/\//i.test(ref)))
throw new Error('Недопустимый адрес файла')
const url = httpURL(
/^https?:\/\//i.test(ref)
? ref
: ref.startsWith('/')
? new URL(ref, server).href
: `${server}/api/files/${encodeURIComponent(ref)}`,
).href
const url = resolveMediaURL(server, ref)
const assetId = hash(url)
assets.set(assetId, { id: assetId, url })
return assetId