mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-20 12:11:28 -07:00
fix: satisfy subtitle cue parser typecheck
This commit is contained in:
@@ -144,13 +144,13 @@ export function parseAssCues(content: string): SubtitleCue[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function detectSubtitleFormat(source: string): 'srt' | 'vtt' | 'ass' | 'ssa' | null {
|
function detectSubtitleFormat(source: string): 'srt' | 'vtt' | 'ass' | 'ssa' | null {
|
||||||
const normalizedSource = (() => {
|
const [normalizedSource = source] = (() => {
|
||||||
try {
|
try {
|
||||||
return /^[a-z]+:\/\//i.test(source) ? new URL(source).pathname : source;
|
return /^[a-z]+:\/\//i.test(source) ? new URL(source).pathname : source;
|
||||||
} catch {
|
} catch {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
})().split(/[?#]/, 1)[0];
|
})().split(/[?#]/, 1);
|
||||||
const ext = normalizedSource.split('.').pop()?.toLowerCase() ?? '';
|
const ext = normalizedSource.split('.').pop()?.toLowerCase() ?? '';
|
||||||
if (ext === 'srt') return 'srt';
|
if (ext === 'srt') return 'srt';
|
||||||
if (ext === 'vtt') return 'vtt';
|
if (ext === 'vtt') return 'vtt';
|
||||||
|
|||||||
Reference in New Issue
Block a user