diff options
author | Chocobozzz <me@florianbigard.com> | 2023-08-30 19:24:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-30 19:24:01 +0200 |
commit | 6495764268348b8f842b4d3ac4c5f1d2026164d6 (patch) | |
tree | 92774a242a51ff3ceaf32d5d31792f09bad4492b | |
parent | 76dbe843d1cd9cb96898bc994f64fabc0e6a48c4 (diff) | |
download | PeerTube-6495764268348b8f842b4d3ac4c5f1d2026164d6.tar.gz PeerTube-6495764268348b8f842b4d3ac4c5f1d2026164d6.tar.zst PeerTube-6495764268348b8f842b4d3ac4c5f1d2026164d6.zip |
Fix chapters extract
-rw-r--r-- | packages/core-utils/src/common/date.ts | 3 | ||||
-rw-r--r-- | packages/tests/src/server-helpers/core-utils.ts | 1 |
2 files changed, 2 insertions, 2 deletions
diff --git a/packages/core-utils/src/common/date.ts b/packages/core-utils/src/common/date.ts index 66899de80..4cabeb93c 100644 --- a/packages/core-utils/src/common/date.ts +++ b/packages/core-utils/src/common/date.ts | |||
@@ -45,7 +45,7 @@ function isLastWeek (d: Date) { | |||
45 | 45 | ||
46 | // --------------------------------------------------------------------------- | 46 | // --------------------------------------------------------------------------- |
47 | 47 | ||
48 | export const timecodeRegexString = `((\\d+)[h:])?((\\d+)[m:])?((\\d+)s?)?` | 48 | export const timecodeRegexString = `((\\d+)[h:])?((\\d+)[m:])?((\\d+)s?)` |
49 | 49 | ||
50 | function timeToInt (time: number | string) { | 50 | function timeToInt (time: number | string) { |
51 | if (!time) return 0 | 51 | if (!time) return 0 |
@@ -53,7 +53,6 @@ function timeToInt (time: number | string) { | |||
53 | 53 | ||
54 | const reg = new RegExp(`^${timecodeRegexString}$`) | 54 | const reg = new RegExp(`^${timecodeRegexString}$`) |
55 | const matches = time.match(reg) | 55 | const matches = time.match(reg) |
56 | |||
57 | if (!matches) return 0 | 56 | if (!matches) return 0 |
58 | 57 | ||
59 | const hours = parseInt(matches[2] || '0', 10) | 58 | const hours = parseInt(matches[2] || '0', 10) |
diff --git a/packages/tests/src/server-helpers/core-utils.ts b/packages/tests/src/server-helpers/core-utils.ts index 0df238e88..13001b137 100644 --- a/packages/tests/src/server-helpers/core-utils.ts +++ b/packages/tests/src/server-helpers/core-utils.ts | |||
@@ -206,6 +206,7 @@ describe('Extract chapters', function () { | |||
206 | expect(parseChapters('my super description\nno?')).to.deep.equal([]) | 206 | expect(parseChapters('my super description\nno?')).to.deep.equal([]) |
207 | expect(parseChapters('m00:00 super description\nno?')).to.deep.equal([]) | 207 | expect(parseChapters('m00:00 super description\nno?')).to.deep.equal([]) |
208 | expect(parseChapters('00:00super description\nno?')).to.deep.equal([]) | 208 | expect(parseChapters('00:00super description\nno?')).to.deep.equal([]) |
209 | expect(parseChapters('my super description\n'.repeat(10) + ' * list1\n * list 2\n * list 3')).to.deep.equal([]) | ||
209 | }) | 210 | }) |
210 | 211 | ||
211 | it('Should extract chapters', function () { | 212 | it('Should extract chapters', function () { |