Support both postgresql:// and posgres:// url prefix

This commit is contained in:
Dan Sosedoff
2015-07-14 22:42:46 -05:00
parent c12853d0b0
commit 785108002e
3 changed files with 14 additions and 2 deletions

View File

@@ -28,7 +28,7 @@ func FormatUrl(opts command.Options) (string, error) {
url := opts.Url
// Make sure to only accept urls in a standard format
if !strings.Contains(url, "postgres://") {
if !strings.HasPrefix(url, "postgres://") && !strings.HasPrefix(url, "postgresql://") {
return "", errors.New("Invalid URL. Valid format: postgres://user:password@host:port/db?sslmode=mode")
}

View File

@@ -12,7 +12,7 @@ import (
func Test_Invalid_Url(t *testing.T) {
opts := command.Options{}
examples := []string{
"postgresql://foobar",
"postgre://foobar",
"foobar",
}