File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -527,7 +527,7 @@ func hasEpochTimestamp(s string) bool {
527
527
528
528
// a valid timestamp can have optional ':' in zone specifier
529
529
// remove that if it exists so we have a single format
530
- if ts [len (ts )- 3 ] == ':' {
530
+ if len ( ts ) >= 3 && ts [len (ts )- 3 ] == ':' {
531
531
ts = ts [:len (ts )- 3 ] + ts [len (ts )- 2 :]
532
532
}
533
533
Original file line number Diff line number Diff line change @@ -724,6 +724,14 @@ func TestHasEpochTimestamp(t *testing.T) {
724
724
Input : "+++ file.txt\t 2019-03-21 12:34:56.789 -0700\n " ,
725
725
Output : false ,
726
726
},
727
+ "notTimestamp" : {
728
+ Input : "+++ file.txt\t random text\n " ,
729
+ Output : false ,
730
+ },
731
+ "notTimestampShort" : {
732
+ Input : "+++ file.txt\t 0\n " ,
733
+ Output : false ,
734
+ },
727
735
}
728
736
729
737
for name , test := range tests {
You can’t perform that action at this time.
0 commit comments