package mongo

import (
	"net/url"
)

func buildURI(s *DBSettings) string {
	u := &url.URL{
		Scheme: "mongodb",
		Host:   s.Host,
		Path:   "/" + url.PathEscape(s.Database), // /my%20db
	}

	q := url.Values{}
	if s.ReplicaSet != "" {
		q.Set("replicaSet", s.ReplicaSet)
	}

	u.RawQuery = q.Encode()

	return u.String()
}
