func FormatURL(opts command.Options) (string, error) {
	url := opts.URL
	if !hasValidPrefix(url) {
		return "", errInvalidURLFormat
	}
	uri, err := neturl.Parse(url)
	if err != nil {
		return "", errInvalidURLFormat
	}
	params := valsFromQuery(uri.Query())
	if params["sslmode"] == "" {
		if opts.Ssl == "" {
			if strings.Contains(uri.Host, "localhost") || strings.Contains(uri.Host, "127.0.0.1") {
				params["sslmode"] = "disable"
			}
		} else {
			params["sslmode"] = opts.Ssl
		}
	}
	query := neturl.Values{}
	for k, v := range params {
		query.Add(k, v)
	}
	uri.RawQuery = query.Encode()
	return uri.String(), nil
}
FormatURL reformats the existing connection string
package connection
import (
	"errors"
	"fmt"
	neturl "net/url"
	"os"
	"os/user"
	"strings"
	"github.com/sosedoff/pgweb/pkg/command"
)
var (
	errCantDetectUser   = errors.New("Could not detect default username")
	errInvalidURLFormat = errors.New("Invalid URL. Valid format: postgres://user:password@host:port/db?sslmode=mode")
)
func currentUser() (string, error) {
	u, err := user.Current()
	if err == nil {
		return u.Username, nil
	}
	name := os.Getenv("USER")
	if name != "" {
		return name, nil
	}
	return "", errCantDetectUser
}
func hasValidPrefix(str string) bool {
	return strings.HasPrefix(str, "postgres://") || strings.HasPrefix(str, "postgresql://")
}
func valsFromQuery(vals neturl.Values) map[string]string {
	result := map[string]string{}
	for k, v := range vals {
		result[strings.ToLower(k)] = v[0]
	}
	return result
}