refactor: replace URI string concatenation with EndsWith check

Replace new Uri(url.TrimEnd('/') + "/") pattern with explicit
EndsWith('/') check to avoid string concatenation inside URI
construction. Applies to 3 locations:
- Program.cs (Heimdall.Web) - HttpClient base address
- TokenRefreshHandler.cs - raw HttpClient for token refresh
- Program.cs (Heimdall.Agent) - Central service client
This commit is contained in:
Arnaud Dartois committed 2026-07-27 18:43:25 +00:00
1 parent 9e58b5bf55
commit 87eb0982a7
3 files changed
+6 -3

No files matched your search

+2 -1
View File
@@ -31,7 +31,8 @@ builder.Services.AddOptions<AgentOptions>()
builder.Services.AddHttpClient("Central", (sp, client) =>
{
var options = sp.GetRequiredService<IOptions<AgentOptions>>().Value;
client.BaseAddress = new Uri(options.CentralUrl.TrimEnd('/') + "/");
var baseUrl = options.CentralUrl.EndsWith('/') ? options.CentralUrl : options.CentralUrl + "/";
client.BaseAddress = new Uri(baseUrl);
client.Timeout = TimeSpan.FromSeconds(10);
});