Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion libsql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@ func extractTls(query *url.Values, scheme string) (bool, error) {
}
}

func extractHost(query *url.Values) string {
host := query.Get("host")
query.Del("host")
return host
}

func (d Driver) Open(dbUrl string) (driver.Conn, error) {
u, err := url.Parse(dbUrl)
if err != nil {
Expand Down Expand Up @@ -314,6 +320,11 @@ func (d Driver) Open(dbUrl string) (driver.Conn, error) {
return nil, err
}

host := extractHost(&query)
if host == "" {
host = u.Host
}

for name := range query {
return nil, fmt.Errorf("unknown query parameter %#v", name)
}
Expand Down Expand Up @@ -341,7 +352,7 @@ func (d Driver) Open(dbUrl string) (driver.Conn, error) {
return ws.Connect(u.String(), jwt)
}
if u.Scheme == "https" || u.Scheme == "http" {
return http.Connect(u.String(), jwt, u.Host, false), nil
return http.Connect(u.String(), jwt, host, false), nil
}

return nil, fmt.Errorf("unsupported URL scheme: %s\nThis driver supports only URLs that start with libsql://, file://, https://, http://, wss:// and ws://", u.Scheme)
Expand Down
Loading