fix: satisfy subtitle cue parser typecheck

This commit is contained in:
2026-03-15 15:33:40 -07:00
parent d069df2124
commit e940205479

View File

@@ -144,13 +144,13 @@ export function parseAssCues(content: string): SubtitleCue[] {
}
function detectSubtitleFormat(source: string): 'srt' | 'vtt' | 'ass' | 'ssa' | null {
const normalizedSource = (() => {
const [normalizedSource = source] = (() => {
try {
return /^[a-z]+:\/\//i.test(source) ? new URL(source).pathname : source;
} catch {
return source;
}
})().split(/[?#]/, 1)[0];
})().split(/[?#]/, 1);
const ext = normalizedSource.split('.').pop()?.toLowerCase() ?? '';
if (ext === 'srt') return 'srt';
if (ext === 'vtt') return 'vtt';