Skip to content

Commit

Permalink
rollup: urlencode postgres url (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes authored Oct 6, 2020
1 parent b1edfd9 commit 930c9f1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions rollup/transaction_ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/ecdsa"
"fmt"
"net/url"
"time"

"errors"
Expand Down Expand Up @@ -162,11 +163,11 @@ func (t *TxIngestion) Stop() {
func DbConnectionString(cfg *Config) string {
if len(cfg.TxIngestionDBUser) > 0 && len(cfg.TxIngestionDBPassword) > 0 {
return fmt.Sprintf("postgresql://%s:%s@%s:%d/%s?sslmode=disable",
cfg.TxIngestionDBUser, cfg.TxIngestionDBPassword, cfg.TxIngestionDBHost, cfg.TxIngestionDBPort, cfg.TxIngestionDBName)
url.QueryEscape(cfg.TxIngestionDBUser), url.QueryEscape(cfg.TxIngestionDBPassword), cfg.TxIngestionDBHost, cfg.TxIngestionDBPort, url.QueryEscape(cfg.TxIngestionDBName))
}
if len(cfg.TxIngestionDBUser) > 0 && len(cfg.TxIngestionDBPassword) == 0 {
return fmt.Sprintf("postgresql://%s@%s:%d/%s?sslmode=disable",
cfg.TxIngestionDBUser, cfg.TxIngestionDBHost, cfg.TxIngestionDBPort, cfg.TxIngestionDBName)
url.QueryEscape(cfg.TxIngestionDBUser), cfg.TxIngestionDBHost, cfg.TxIngestionDBPort, cfg.TxIngestionDBName)
}
return fmt.Sprintf("postgresql://%s:%d/%s?sslmode=disable", cfg.TxIngestionDBHost, cfg.TxIngestionDBPort, cfg.TxIngestionDBName)
}

0 comments on commit 930c9f1

Please sign in to comment.