Add project files
This commit is contained in:
parent
4dafed3553
commit
8cf01ead74
40 changed files with 3967 additions and 0 deletions
22
StalwartSimpleLoginMiddleware/Utilities/ConnectionHelper.cs
Normal file
22
StalwartSimpleLoginMiddleware/Utilities/ConnectionHelper.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue