From 04d18aa8ed4ff932dc6c9d102c217894f7dd4b4e Mon Sep 17 00:00:00 2001 From: Avinash Sajjanshetty Date: Sat, 9 Dec 2023 19:56:52 +0530 Subject: [PATCH] bugfix: handle trailing slash in the request URL --- libsql/internal/http/hranaV2/hranaV2.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libsql/internal/http/hranaV2/hranaV2.go b/libsql/internal/http/hranaV2/hranaV2.go index abc5c27..e643d48 100644 --- a/libsql/internal/http/hranaV2/hranaV2.go +++ b/libsql/internal/http/hranaV2/hranaV2.go @@ -8,13 +8,15 @@ import ( "encoding/json" "errors" "fmt" - "github.com/libsql/libsql-client-go/libsql/internal/hrana" - "github.com/libsql/libsql-client-go/libsql/internal/http/shared" "io" "net/http" + net_url "net/url" "runtime/debug" "strings" "time" + + "github.com/libsql/libsql-client-go/libsql/internal/hrana" + "github.com/libsql/libsql-client-go/libsql/internal/http/shared" ) var commitHash string @@ -182,7 +184,11 @@ func sendPipelineRequest(ctx context.Context, msg *hrana.PipelineRequest, url st } ctx, cancel := context.WithTimeout(ctx, 60*time.Second) defer cancel() - req, err := http.NewRequestWithContext(ctx, "POST", url+"/v2/pipeline", bytes.NewReader(reqBody)) + pipelineURL, err := net_url.JoinPath(url, "/v2/pipeline") + if err != nil { + return hrana.PipelineResponse{}, false, err + } + req, err := http.NewRequestWithContext(ctx, "POST", pipelineURL, bytes.NewReader(reqBody)) if err != nil { return hrana.PipelineResponse{}, false, err }