Skip to content

Commit

Permalink
Merge pull request #9 from bcgov/dev
Browse files Browse the repository at this point in the history
chore: dbhost
  • Loading branch information
ychung-mot authored Mar 14, 2024
2 parents f36cdc8 + f40123b commit 8cb1ff6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions server/StrDss.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using StrDss.Service;
using StrDss.Service.HttpClients;
using System.Reflection;
using StrDss.Common;

var builder = WebApplication.CreateBuilder(args);

Expand All @@ -21,12 +22,12 @@
options.AddServerHeader = false;
});

var dbHost = builder.Configuration.GetValue<string>("DB_HOST");
var dbHost = builder.Configuration.GetValue<string>("DB_HOST") ?? "";
var dbName = builder.Configuration.GetValue<string>("DB_NAME");
var dbUser = builder.Configuration.GetValue<string>("DB_USER");
var dbPass = builder.Configuration.GetValue<string>("DB_PASS");
var dbPort = builder.Configuration.GetValue<string>("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};";

Check failure on line 30 in server/StrDss.Api/Program.cs

View workflow job for this annotation

GitHub Actions / test-backend

'string' does not contain a definition for 'GetStringBeforeFirstDot' and no accessible extension method 'GetStringBeforeFirstDot' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 30 in server/StrDss.Api/Program.cs

View workflow job for this annotation

GitHub Actions / test-backend

'string' does not contain a definition for 'GetStringBeforeFirstDot' and no accessible extension method 'GetStringBeforeFirstDot' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)

builder.Services.AddHttpContextAccessor();

Expand Down
11 changes: 10 additions & 1 deletion server/StrDss.Common/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,22 @@ 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 "";

var lastDotIndex = input.LastIndexOf('.');

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;
}
}
}

0 comments on commit 8cb1ff6

Please sign in to comment.