< Summary - Syki

Information
Class: Syki.Back.Settings.FrontendSettings
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Settings/FrontendSettings.cs
Tag: 56_26538939494
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 37
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Url()100%210%
.ctor(...)0%620%
BuildUrl(...)0%4260%

File(s)

/home/runner/work/syki/syki/Back/Settings/FrontendSettings.cs

#LineLine coverage
 1namespace Syki.Back.Settings;
 2
 3public class FrontendSettings
 4{
 5    /// <summary>
 6    /// Base URL of the frontend application (e.g., http://localhost:3000).
 7    /// Used for redirects after SSO login and other cross-origin flows.
 8    /// </summary>
 09    public string Url { get; set; }
 10
 011    public FrontendSettings(IConfiguration configuration)
 12    {
 013        configuration.GetSection("Frontend").Bind(this);
 14
 015        if (Url.IsEmpty()) throw new InvalidOperationException("Frontend:Url is required.");
 16
 017        Url = Url.TrimEnd('/');
 018    }
 19
 20    /// <summary>
 21    /// Builds a full URL for a frontend path.
 22    /// </summary>
 23    public string BuildUrl(string path = "/")
 24    {
 025        if (path.IsEmpty() || path == "/") return Url;
 26
 027        return $"{Url}{(path.StartsWith('/') ? path : $"/{path}")}";
 28    }
 29}
 30
 31public static class FrontendSettingsExtensions
 32{
 33    extension(IConfiguration configuration)
 34    {
 35        public FrontendSettings Frontend => new(configuration);
 36    }
 37}