fix: align WebVTT detection with cue boundaries

This commit is contained in:
Palash Debnath
2026-09-17 12:16:41 +05:30
parent 52962e47c6
commit a33db40613
4 changed files with 12 additions and 2 deletions
@@ -426,3 +426,8 @@ describe('DubPasteTranslationDialog', () => {
expect(screen.getByRole('button', { name: /Apply/i })).toBeDisabled();
});
});
it('keeps an hourless timestamp embedded in prose as plain text', () => {
expect(detectPasteMode('Continue at 01:30.000 --> the finale')).toBe('plain');
});
+1 -1
View File
@@ -26,7 +26,7 @@
// A timing line, e.g. `00:00:01,000 --> 00:00:04,500` (`.` ms separator,
// missing leading zeros and WebVTT's hourless `00:01.000` allowed — mirrors
// backend/services/srt_parser.py).
const TIMING_RE = /(?:\d{1,2}:)?[0-5]?\d:[0-5]?\d[,.]\d{1,3}\s*-->/;
const TIMING_RE = /^[^\S\n]*(?:\d{1,2}:)?[0-5]?\d:[0-5]?\d[,.]\d{1,3}[^\S\n]*-->/m;
// `1. text` / `2) text` / `[3] text` / `4 - text` / `5: text`.
const NUMBERED_RE = /^\s*(?:\[\s*(\d{1,5})\s*\]|\(\s*(\d{1,5})\s*\)|(\d{1,5}))\s*[.):\-—]?\s+(.*)$/;