Skip to content

Commit

Permalink
feat: map session cookie expires to zero time value #1159 (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvii authored Dec 7, 2024
1 parent 686e0ad commit 393ac0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/proto/a_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"reflect"
"time"

"github.com/go-rod/rod/lib/proto"
"github.com/go-rod/rod/lib/utils"
Expand Down Expand Up @@ -73,6 +74,10 @@ func (t T) TimeCodec() {
data, err = json.Marshal(datetime)
t.E(err)
t.Eq(raw, data)

var sessionExpires proto.TimeSinceEpoch = -1
var zeroTime time.Time
t.Eq(sessionExpires.Time(), zeroTime)
}

func (t T) Rect() {
Expand Down
3 changes: 3 additions & 0 deletions lib/proto/a_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type TimeSinceEpoch float64

// Time interface.
func (t TimeSinceEpoch) Time() time.Time {
if t == -1 {
return time.Time{}
}
return (time.Unix(0, 0)).Add(
time.Duration(t * TimeSinceEpoch(time.Second)),
)
Expand Down

0 comments on commit 393ac0d

Please sign in to comment.