File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ * Allowed the use of DSN without specifying the protocol/scheme
12* Removed public ` query.Identifier ` interface for exclude any external implementations for use with YDB
23
34## v3.74.0
Original file line number Diff line number Diff line change @@ -3,13 +3,16 @@ package dsn
33import (
44 "fmt"
55 "net/url"
6+ "regexp"
67
78 "github.com/ydb-platform/ydb-go-sdk/v3/config"
89 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
910)
1011
1112var (
1213 insecureSchema = "grpc"
14+ secureSchema = "grpcs"
15+ reScheme = regexp .MustCompile (`^\w+://` )
1316 databaseParam = "database"
1417)
1518
@@ -25,7 +28,13 @@ type parsedInfo struct {
2528}
2629
2730func Parse (dsn string ) (info parsedInfo , err error ) {
28- uri , err := url .Parse (dsn )
31+ uri , err := url .ParseRequestURI (func () string {
32+ if reScheme .MatchString (dsn ) {
33+ return dsn
34+ }
35+
36+ return secureSchema + "://" + dsn
37+ }())
2938 if err != nil {
3039 return info , xerrors .WithStackTrace (err )
3140 }
Original file line number Diff line number Diff line change @@ -104,6 +104,22 @@ func TestParseConnectionString(t *testing.T) {
104104 "" ,
105105 "" ,
106106 },
107+ {
108+ "localhost:3049/Root" ,
109+ true ,
110+ "localhost:3049" ,
111+ "/Root" ,
112+ "" ,
113+ "" ,
114+ },
115+ {
116+ "grpc://localhost:3049/Root" ,
117+ false ,
118+ "localhost:3049" ,
119+ "/Root" ,
120+ "" ,
121+ "" ,
122+ },
107123 } {
108124 t .Run (test .connectionString , func (t * testing.T ) {
109125 info , err := Parse (test .connectionString )
You can’t perform that action at this time.
0 commit comments