mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
allow hosts with prefix "/" , without escaping (#363)
* allow hosts with prefix "/" , without escaping * add comment and fix code style * fix bug * Remove duplicate format call * Update lib/pq * try to fix goSec setup error Co-authored-by: RW <rene@gofiber.io> Co-authored-by: hi019 <65871571+hi019@users.noreply.github.com>
This commit is contained in:
@@ -56,12 +56,16 @@ func New(config ...Config) *Storage {
|
||||
if cfg.Username != "" || cfg.Password != "" {
|
||||
dsn += "@"
|
||||
}
|
||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||
// unix socket host path
|
||||
if strings.HasPrefix(cfg.Host, "/") {
|
||||
dsn += fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
|
||||
} else {
|
||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||
}
|
||||
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
|
||||
url.QueryEscape(cfg.Database),
|
||||
int64(cfg.timeout.Seconds()),
|
||||
cfg.SslMode,
|
||||
)
|
||||
cfg.SslMode)
|
||||
|
||||
// Create db
|
||||
db, err := sql.Open("postgres", dsn)
|
||||
|
Reference in New Issue
Block a user