Skip to content

Commit 61fc1d2

Browse files
committed
Fix zero start time breaking
1 parent dabc63a commit 61fc1d2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/utils/exporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
3838
const match = line.match(/(?:((?:\d+:)?\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g);
3939
if (match) {
4040
const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]);
41-
if (startTime) {
41+
if (startTime !== null) {
4242
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:()\s]+$/g
4343
const titleLeft = line.split(match[0])[0].replace(specialCharsMatcher, "");
4444
let titleRight = null;

test/exporter.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,25 @@ describe("Import segments", () => {
254254
category: "chapter" as Category
255255
}]);
256256
});
257+
258+
it ("00:00", () => {
259+
const input = ` 00:00 Cap 1
260+
00:10 Cap 2
261+
00:12 Cap 3`;
262+
263+
const result = importTimes(input, 8000);
264+
expect(result).toMatchObject([{
265+
segment: [0, 10],
266+
description: "Cap 1",
267+
category: "chapter" as Category
268+
}, {
269+
segment: [10, 12],
270+
description: "Cap 2",
271+
category: "chapter" as Category
272+
}, {
273+
segment: [12, 8000],
274+
description: "Cap 3",
275+
category: "chapter" as Category
276+
}]);
277+
});
257278
});

0 commit comments

Comments
 (0)