Skip to content

Commit 393ac0d

Browse files
authored
feat: map session cookie expires to zero time value #1159 (#1160)
1 parent 686e0ad commit 393ac0d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/proto/a_interface_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"reflect"
8+
"time"
89

910
"github.com/go-rod/rod/lib/proto"
1011
"github.com/go-rod/rod/lib/utils"
@@ -73,6 +74,10 @@ func (t T) TimeCodec() {
7374
data, err = json.Marshal(datetime)
7475
t.E(err)
7576
t.Eq(raw, data)
77+
78+
var sessionExpires proto.TimeSinceEpoch = -1
79+
var zeroTime time.Time
80+
t.Eq(sessionExpires.Time(), zeroTime)
7681
}
7782

7883
func (t T) Rect() {

lib/proto/a_patch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type TimeSinceEpoch float64
1616

1717
// Time interface.
1818
func (t TimeSinceEpoch) Time() time.Time {
19+
if t == -1 {
20+
return time.Time{}
21+
}
1922
return (time.Unix(0, 0)).Add(
2023
time.Duration(t * TimeSinceEpoch(time.Second)),
2124
)

0 commit comments

Comments
 (0)