File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ func (e *Exporter) discoverDatabaseDSNs() []string {
3535 var dsnURI * url.URL
3636 var dsnConnstring string
3737
38- if strings .HasPrefix (dsn , "postgresql://" ) {
38+ if strings .HasPrefix (dsn , "postgresql://" ) || strings . HasPrefix ( dsn , "postgres://" ) {
3939 var err error
4040 dsnURI , err = url .Parse (dsn )
4141 if err != nil {
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ func (d DSN) GetConnectionString() string {
6565// dsnFromString parses a connection string into a dsn. It will attempt to parse the string as
6666// a URL and as a set of key=value pairs. If both attempts fail, dsnFromString will return an error.
6767func dsnFromString (in string ) (DSN , error ) {
68- if strings .HasPrefix (in , "postgresql://" ) {
68+ if strings .HasPrefix (in , "postgresql://" ) || strings . HasPrefix ( in , "postgres://" ) {
6969 return dsnFromURL (in )
7070 }
7171
Original file line number Diff line number Diff line change @@ -186,6 +186,19 @@ func Test_dsnFromString(t *testing.T) {
186186 },
187187 wantErr : false ,
188188 },
189+ {
190+ name : "Alternative URL prefix" ,
191+ input :
"postgres://user:[email protected] :5432/tsdb?user=postgres" ,
192+ want : DSN {
193+ scheme : "postgres" ,
194+ host : "host.example.com:5432" ,
195+ path : "/tsdb" ,
196+ query : url.Values {},
197+ username : "user" ,
198+ password : "s3cret" ,
199+ },
200+ wantErr : false ,
201+ },
189202 {
190203 name : "URL with user and password in query string" ,
191204 input : "postgresql://host.example.com:5432/tsdb?user=postgres&password=s3cr3t" ,
You can’t perform that action at this time.
0 commit comments