Skip to content

Commit

Permalink
fix: more robust filename support (#18)
Browse files Browse the repository at this point in the history
* fix: more robust filename support

* fix linting

* ignored captures
  • Loading branch information
jfo authored Mar 6, 2025
1 parent 1b6f937 commit 702a31b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,18 @@ async function getPublicVersion () {
}

function isInRange ({ filename, from, to }) {
const date = parse(filename.split('.pcap')[0].split('-')[0], 'yyyy/MM/dd/HH/mm', new Date())
const isInRage = from < date && date < to
return isInRage
const regex =
/(\d{4})\/(\d{2})\/(\d{2})\/(\d{2})\/(\d{2})(?:(\d{2})|-(\d{2}))?(?:-(.+))?\.pcap/
const match = filename.match(regex)
const [_out, year, month, day, hour, minute, concatSeconds, dashSeconds, _tag] =
match
const second = concatSeconds || dashSeconds || '00'

const dateString = `${year}-${month}-${day} ${hour}:${minute}:${second}`
const date = parse(dateString, 'yyyy-MM-dd HH:mm:ss', new Date())

const isInRange = from < date && date < to
return isInRange
}

function exit (err) {
Expand Down

0 comments on commit 702a31b

Please sign in to comment.