22 lines
No EOL
597 B
C#
22 lines
No EOL
597 B
C#
using Npgsql;
|
|
|
|
namespace StalwartSimpleLoginMiddleware.Utilities;
|
|
|
|
public static class ConnectionHelper
|
|
{
|
|
public static string GetPostgresConnectionString(string url)
|
|
{
|
|
var uri = new Uri(url);
|
|
var userInfo = uri.UserInfo.Split(':');
|
|
var builder = new NpgsqlConnectionStringBuilder
|
|
{
|
|
Host = uri.Host,
|
|
Port = uri.Port,
|
|
Database = uri.AbsolutePath.Trim('/'),
|
|
Username = userInfo[0],
|
|
Password = userInfo[1],
|
|
SslMode = SslMode.Prefer
|
|
};
|
|
return builder.ToString();
|
|
}
|
|
} |