Skip to content

Commit b74e599

Browse files
authored
Merge pull request #16 from perhamm/main
fix snapshot without date in name
2 parents 75141b0 + c526bb4 commit b74e599

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

modules/router/router.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
378378
}
379379
if !matched {
380380
match := re.FindStringSubmatch(n.Snapshot)
381+
if len(match) < 3 {
382+
log.Println("Skip snapshot with unexpected name:", n.Snapshot)
383+
continue
384+
}
381385
n.CreateDate = match[2]
382386
d, err := time.Parse("2006.01.02", n.CreateDate)
383387
n.CreateEpoch = d.Unix()
@@ -392,6 +396,10 @@ func (rt *Router) ApiHandler(w http.ResponseWriter, r *http.Request) {
392396
} else {
393397
for _, n := range snap_resp.Snapshots {
394398
match := re.FindStringSubmatch(n.Snapshot)
399+
if len(match) < 3 {
400+
log.Println("Skip snapshot with unexpected name:", n.Snapshot)
401+
continue
402+
}
395403
n.CreateDate = match[2]
396404
d, err := time.Parse("2006.01.02", n.CreateDate)
397405
n.CreateEpoch = d.Unix()

0 commit comments

Comments
 (0)