Skip to content

Commit

Permalink
fix: correct argument indices for client instantiation
Browse files Browse the repository at this point in the history
Fixes incorrect argument indices for client instantiation. The indexing
of arguments over the JS / Go bridge is zero-based, which was conflated
with the indexing of VU's, which is one-based.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Jul 25, 2023
1 parent 903ebc3 commit db0277f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions coap/coap.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
)

const (
endpointArgIdx = 1
pskIDEnvArgIdx = 2
pskEnvArgIdx = 3
certPathArgIdx = 4
keyPathArgIdx = 5
endpointArgIdx = 0
pskIDEnvArgIdx = 1
pskEnvArgIdx = 2
certPathArgIdx = 3
keyPathArgIdx = 4
)

// Message is a CoAP message.
Expand Down Expand Up @@ -81,7 +81,7 @@ func (c *CoAP) client(cc goja.ConstructorCall) *goja.Object {
return nil
}
certBlock, _ := pem.Decode(pemCert)
pemKey, err := os.ReadFile(filepath.Clean(cc.Argument(certPathArgIdx).String()))
pemKey, err := os.ReadFile(filepath.Clean(cc.Argument(keyPathArgIdx).String()))
if err != nil {
common.Throw(rt, err)
return nil
Expand Down

0 comments on commit db0277f

Please sign in to comment.