aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/utils/exporter.ts2
-rw-r--r--test/exporter.test.ts21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/utils/exporter.ts b/src/utils/exporter.ts
index 813fcd2f..16b970f3 100644
--- a/src/utils/exporter.ts
+++ b/src/utils/exporter.ts
@@ -38,7 +38,7 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
const match = line.match(/(?:((?:\d+:)?\d+:\d+)+(?:\.\d+)?)|(?:\d+(?=s| second))/g);
if (match) {
const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]);
- if (startTime) {
+ if (startTime !== null) {
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:()\s]+$/g
const titleLeft = line.split(match[0])[0].replace(specialCharsMatcher, "");
let titleRight = null;
diff --git a/test/exporter.test.ts b/test/exporter.test.ts
index 3093d1b8..a3af0c04 100644
--- a/test/exporter.test.ts
+++ b/test/exporter.test.ts
@@ -254,4 +254,25 @@ describe("Import segments", () => {
category: "chapter" as Category
}]);
});
+
+ it ("00:00", () => {
+ const input = ` 00:00 Cap 1
+ 00:10 Cap 2
+ 00:12 Cap 3`;
+
+ const result = importTimes(input, 8000);
+ expect(result).toMatchObject([{
+ segment: [0, 10],
+ description: "Cap 1",
+ category: "chapter" as Category
+ }, {
+ segment: [10, 12],
+ description: "Cap 2",
+ category: "chapter" as Category
+ }, {
+ segment: [12, 8000],
+ description: "Cap 3",
+ category: "chapter" as Category
+ }]);
+ });
}); \ No newline at end of file