Fix chapters extract
This commit is contained in:
parent
76dbe843d1
commit
6495764268
|
@ -45,7 +45,7 @@ function isLastWeek (d: Date) {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
export const timecodeRegexString = `((\\d+)[h:])?((\\d+)[m:])?((\\d+)s?)?`
|
export const timecodeRegexString = `((\\d+)[h:])?((\\d+)[m:])?((\\d+)s?)`
|
||||||
|
|
||||||
function timeToInt (time: number | string) {
|
function timeToInt (time: number | string) {
|
||||||
if (!time) return 0
|
if (!time) return 0
|
||||||
|
@ -53,7 +53,6 @@ function timeToInt (time: number | string) {
|
||||||
|
|
||||||
const reg = new RegExp(`^${timecodeRegexString}$`)
|
const reg = new RegExp(`^${timecodeRegexString}$`)
|
||||||
const matches = time.match(reg)
|
const matches = time.match(reg)
|
||||||
|
|
||||||
if (!matches) return 0
|
if (!matches) return 0
|
||||||
|
|
||||||
const hours = parseInt(matches[2] || '0', 10)
|
const hours = parseInt(matches[2] || '0', 10)
|
||||||
|
|
|
@ -206,6 +206,7 @@ describe('Extract chapters', function () {
|
||||||
expect(parseChapters('my super description\nno?')).to.deep.equal([])
|
expect(parseChapters('my super description\nno?')).to.deep.equal([])
|
||||||
expect(parseChapters('m00:00 super description\nno?')).to.deep.equal([])
|
expect(parseChapters('m00:00 super description\nno?')).to.deep.equal([])
|
||||||
expect(parseChapters('00:00super description\nno?')).to.deep.equal([])
|
expect(parseChapters('00:00super description\nno?')).to.deep.equal([])
|
||||||
|
expect(parseChapters('my super description\n'.repeat(10) + ' * list1\n * list 2\n * list 3')).to.deep.equal([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should extract chapters', function () {
|
it('Should extract chapters', function () {
|
||||||
|
|
Loading…
Reference in New Issue