Parse URI-encoded connection strings as URIs.

CockroachDB is frequently referenced as: `cockroachdb://` as its
scheme.  Be scheme name agnostic.
pull/388/head
Sean Chittenden 2018-02-02 16:09:58 -08:00
parent da3231b0b6
commit 6cfb436397
No known key found for this signature in database
GPG Key ID: 4EBC9DC16C2E5E16
1 changed files with 1 additions and 1 deletions

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)