Skip to content

Commit

Permalink
dont panic when limit is larger then actual slice
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Nov 23, 2023
1 parent 9463c82 commit 0eb9d17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions v4/store/nats-js/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,10 @@ func (n *natsStore) List(opts ...store.ListOption) ([]string, error) {
keys = append(keys, key)
}

if opt.Limit > 0 {
if opt.Limit > 0 && int(opt.Offset+opt.Limit) < len(keys) {
return keys[opt.Offset : opt.Offset+opt.Limit], nil
}
if opt.Offset > 0 {
if opt.Offset > 0 && int(opt.Offset) < len(keys) {
return keys[opt.Offset:], nil
}
return keys, nil
Expand Down

0 comments on commit 0eb9d17

Please sign in to comment.