mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-11 18:14:15 +01:00
Backport #28865 by @sdvcrx
Fix #28864
Co-authored-by: sdvcrx <memory.silentvoyage@gmail.com>
(cherry picked from commit 8c7bda8755
)
This commit is contained in:
parent
6aa5554161
commit
131a8f0324
2 changed files with 10 additions and 2 deletions
|
@ -170,8 +170,8 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbsslMode s
|
||||||
RawQuery: dbParam,
|
RawQuery: dbParam,
|
||||||
}
|
}
|
||||||
query := connURL.Query()
|
query := connURL.Query()
|
||||||
if strings.HasPrefix(dbHost, "/") { // looks like a unix socket
|
if strings.HasPrefix(host, "/") { // looks like a unix socket
|
||||||
query.Add("host", dbHost)
|
query.Add("host", host)
|
||||||
connURL.Host = ":" + port
|
connURL.Host = ":" + port
|
||||||
}
|
}
|
||||||
query.Set("sslmode", dbsslMode)
|
query.Set("sslmode", dbsslMode)
|
||||||
|
|
|
@ -77,6 +77,14 @@ func Test_getPostgreSQLConnectionString(t *testing.T) {
|
||||||
SSLMode: "false",
|
SSLMode: "false",
|
||||||
Output: "postgres://testuser:space%20space%20%21%23$%25%5E%5E%25%5E%60%60%60-=%3F=@:5432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false",
|
Output: "postgres://testuser:space%20space%20%21%23$%25%5E%5E%25%5E%60%60%60-=%3F=@:5432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Host: "/tmp/pg.sock:6432",
|
||||||
|
User: "testuser",
|
||||||
|
Passwd: "pass",
|
||||||
|
Name: "gitea",
|
||||||
|
SSLMode: "false",
|
||||||
|
Output: "postgres://testuser:pass@:6432/gitea?host=%2Ftmp%2Fpg.sock&sslmode=false",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Host: "localhost",
|
Host: "localhost",
|
||||||
User: "pgsqlusername",
|
User: "pgsqlusername",
|
||||||
|
|
Loading…
Reference in a new issue