77 "fmt"
88 "io"
99 "net/http"
10- "path "
10+ "net/url "
1111 "strconv"
1212
1313 "github.com/scroll-tech/go-ethereum/common"
3030
3131func NewBeaconNodeClient (apiEndpoint string , l1Client * rollup_sync_service.L1Client ) (* BeaconNodeClient , error ) {
3232 // get genesis time
33- genesisPath := path .Join (apiEndpoint , beaconNodeGenesisEndpoint )
33+ genesisPath , err := url .JoinPath (apiEndpoint , beaconNodeGenesisEndpoint )
34+ if err != nil {
35+ return nil , fmt .Errorf ("failed to join path, err: %w" , err )
36+ }
3437 resp , err := http .Get (genesisPath )
3538 if err != nil {
3639 return nil , fmt .Errorf ("cannot do request, err: %w" , err )
@@ -54,7 +57,10 @@ func NewBeaconNodeClient(apiEndpoint string, l1Client *rollup_sync_service.L1Cli
5457 }
5558
5659 // get seconds per slot from spec
57- specPath := path .Join (apiEndpoint , beaconNodeSpecEndpoint )
60+ specPath , err := url .JoinPath (apiEndpoint , beaconNodeSpecEndpoint )
61+ if err != nil {
62+ return nil , fmt .Errorf ("failed to join path, err: %w" , err )
63+ }
5864 resp , err = http .Get (specPath )
5965 if err != nil {
6066 return nil , fmt .Errorf ("cannot do request, err: %w" , err )
@@ -97,7 +103,10 @@ func (c *BeaconNodeClient) GetBlobByVersionedHashAndBlockNumber(ctx context.Cont
97103 slot := (header .Time - c .genesisTime ) / c .secondsPerSlot
98104
99105 // get blob sidecar for slot
100- blobSidecarPath := path .Join (c .apiEndpoint , beaconNodeBlobEndpoint , fmt .Sprintf ("%d" , slot ))
106+ blobSidecarPath , err := url .JoinPath (c .apiEndpoint , beaconNodeBlobEndpoint , fmt .Sprintf ("%d" , slot ))
107+ if err != nil {
108+ return nil , fmt .Errorf ("failed to join path, err: %w" , err )
109+ }
101110 resp , err := http .Get (blobSidecarPath )
102111 if err != nil {
103112 return nil , fmt .Errorf ("cannot do request, err: %w" , err )
0 commit comments