add crlf case

pull/2233/head
Mikael Finstad 1 year ago
parent bce16eb7b9
commit 349a1a7a70
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -63,6 +63,16 @@ describe('parseYouTube', () => {
{ start: 0, end: undefined, name: 'Test 1' },
]);
});
// possibly https://github.com/mifi/lossless-cut/issues/2344
it('Windows crlf', () => {
const str = ' 00:00: Test 1\r\n00:01: Test 2';
const edl = parseYouTube(str);
expect(edl).toEqual([
{ start: 0, end: 1, name: 'Test 1' },
{ start: 1, end: undefined, name: 'Test 2' },
]);
});
});
it('formatYouTube', () => {

@ -289,7 +289,7 @@ export function parseYouTube(str: string) {
return { time, name };
}
const lines = str.split('\n').map((line) => parseLine(line)).flatMap((line) => (line ? [line] : []));
const lines = str.split(/\r?\n/).map((line) => parseLine(line)).flatMap((line) => (line ? [line] : []));
const linesSorted = sortBy(lines, (l) => l.time);

Loading…
Cancel
Save