| 1 | const REMOTE_RUNTIME_RESOURCE_RE = |
| 2 | /<(script|link)\b[^>]*(?:src|href)\s*=\s*["'](?:https?:)?\/\/[^"']+["'][^>]*>/gi |
| 3 | |
| 4 | /** Returns the external runtime resources forbidden in persisted slide HTML. */ |
| 5 | export const extractRemoteRuntimeResources = (content: string): string[] => { |
| 6 | const hits: string[] = [] |
| 7 | REMOTE_RUNTIME_RESOURCE_RE.lastIndex = 0 |
| 8 | let match: RegExpExecArray | null |
| 9 | while ((match = REMOTE_RUNTIME_RESOURCE_RE.exec(content)) !== null) { |
| 10 | const raw = match[0].replace(/\s+/g, ' ').trim() |
| 11 | hits.push(raw.length > 200 ? `${raw.slice(0, 200)}…` : raw) |
| 12 | if (hits.length >= 8) break |
| 13 | } |
| 14 | return hits |
| 15 | } |
| 16 |