Don't remove trailing end bracket when not starting with bracket

This commit is contained in:
Ajay 2022-12-19 16:12:51 -05:00
parent 3379189ea8
commit 35b8a34162
2 changed files with 18 additions and 1 deletions

View file

@ -39,7 +39,8 @@ export function importTimes(data: string, videoDuration: number): SponsorTime[]
if (match) {
const startTime = GenericUtils.getFormattedTimeToSeconds(match[0]);
if (startTime !== null) {
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:()\s]+$/g
// Remove "seconds", "at", special characters, and ")" if there was a "("
const specialCharsMatcher = /^(?:\s+seconds?)?[-:()\s]*|(?:\s+at)?[-:(\s]+$|(?<=^\s*\(.+)[-:()\s]*$/g
const titleLeft = line.split(match[0])[0].replace(specialCharsMatcher, "");
let titleRight = null;
const split2 = line.split(match[1] || match[0]);

View file

@ -275,4 +275,20 @@ describe("Import segments", () => {
category: "chapter" as Category
}]);
});
it ("0:00 G¹ (Tangent Continuity)", () => {
const input = ` 0:00 G¹ (Tangent Continuity)
0:01 G² (Tangent Continuity)`;
const result = importTimes(input, 8000);
expect(result).toMatchObject([{
segment: [0, 1],
description: "G¹ (Tangent Continuity)",
category: "chapter" as Category
}, {
segment: [1, 8000],
description: "G² (Tangent Continuity)",
category: "chapter" as Category
}]);
});
});