diff --git a/server/StrDss.Api/Program.cs b/server/StrDss.Api/Program.cs index 759a242f..6f3d4188 100644 --- a/server/StrDss.Api/Program.cs +++ b/server/StrDss.Api/Program.cs @@ -13,6 +13,7 @@ using StrDss.Service; using StrDss.Service.HttpClients; using System.Reflection; +using StrDss.Common; var builder = WebApplication.CreateBuilder(args); @@ -21,12 +22,12 @@ options.AddServerHeader = false; }); -var dbHost = builder.Configuration.GetValue("DB_HOST"); +var dbHost = builder.Configuration.GetValue("DB_HOST") ?? ""; var dbName = builder.Configuration.GetValue("DB_NAME"); var dbUser = builder.Configuration.GetValue("DB_USER"); var dbPass = builder.Configuration.GetValue("DB_PASS"); var dbPort = builder.Configuration.GetValue("DB_PORT"); -var connString = $"Host={dbHost};Username={dbUser};Password={dbPass};Database={dbName};Port={dbPort};"; +var connString = $"Host={dbHost.GetStringBeforeFirstDot()};Username={dbUser};Password={dbPass};Database={dbName};Port={dbPort};"; builder.Services.AddHttpContextAccessor(); diff --git a/server/StrDss.Common/CommonExtensions.cs b/server/StrDss.Common/CommonExtensions.cs index dec91f5a..dbfac50e 100644 --- a/server/StrDss.Common/CommonExtensions.cs +++ b/server/StrDss.Common/CommonExtensions.cs @@ -187,7 +187,7 @@ public static string ComputeSHA256Hash(this string input) } } - public static string GetWordAfterLastDot(this string input) + public static string GetStringAfterLastDot(this string input) { if (input.IsEmpty()) return ""; @@ -195,5 +195,14 @@ public static string GetWordAfterLastDot(this string input) return lastDotIndex >= 0 ? input.Substring(lastDotIndex + 1) : input; } + + public static string GetStringBeforeDot(string input) + { + if (input.IsEmpty()) return ""; + + int dotIndex = input.IndexOf('.'); + + return dotIndex > 0 ? input.Substring(0, dotIndex) : input; + } } }