Skip to content

Commit 702a31b

Browse files
authored
fix: more robust filename support (#18)
* fix: more robust filename support * fix linting * ignored captures
1 parent 1b6f937 commit 702a31b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,18 @@ async function getPublicVersion () {
430430
}
431431

432432
function isInRange ({ filename, from, to }) {
433-
const date = parse(filename.split('.pcap')[0].split('-')[0], 'yyyy/MM/dd/HH/mm', new Date())
434-
const isInRage = from < date && date < to
435-
return isInRage
433+
const regex =
434+
/(\d{4})\/(\d{2})\/(\d{2})\/(\d{2})\/(\d{2})(?:(\d{2})|-(\d{2}))?(?:-(.+))?\.pcap/
435+
const match = filename.match(regex)
436+
const [_out, year, month, day, hour, minute, concatSeconds, dashSeconds, _tag] =
437+
match
438+
const second = concatSeconds || dashSeconds || '00'
439+
440+
const dateString = `${year}-${month}-${day} ${hour}:${minute}:${second}`
441+
const date = parse(dateString, 'yyyy-MM-dd HH:mm:ss', new Date())
442+
443+
const isInRange = from < date && date < to
444+
return isInRange
436445
}
437446

438447
function exit (err) {

0 commit comments

Comments
 (0)