2
0

Parse URI-encoded connection strings as URIs.

CockroachDB is frequently referenced as: `cockroachdb://` as its
scheme.  Be scheme name agnostic.
This commit is contained in:
Sean Chittenden
2018-02-02 16:09:58 -08:00
parent da3231b0b6
commit 6cfb436397
+1 -1
View File
@@ -792,7 +792,7 @@ func ParseDSN(s string) (ConnConfig, error) {
// ParseConnectionString parses either a URI or a DSN connection string.
// see ParseURI and ParseDSN for details.
func ParseConnectionString(s string) (ConnConfig, error) {
if strings.HasPrefix(s, "postgres://") || strings.HasPrefix(s, "postgresql://") {
if u, err := url.Parse(s); err == nil && u.Scheme != "" {
return ParseURI(s)
}
return ParseDSN(s)