< Summary - Syki

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Frontend(...)100%210%

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>
 9    public string Url { get; set; }
 10
 11    public FrontendSettings(IConfiguration configuration)
 12    {
 13        configuration.GetSection("Frontend").Bind(this);
 14
 15        if (Url.IsEmpty()) throw new InvalidOperationException("Frontend:Url is required.");
 16
 17        Url = Url.TrimEnd('/');
 18    }
 19
 20    /// <summary>
 21    /// Builds a full URL for a frontend path.
 22    /// </summary>
 23    public string BuildUrl(string path = "/")
 24    {
 25        if (path.IsEmpty() || path == "/") return Url;
 26
 27        return $"{Url}{(path.StartsWith('/') ? path : $"/{path}")}";
 28    }
 29}
 30
 31public static class FrontendSettingsExtensions
 32{
 33    extension(IConfiguration configuration)
 34    {
 035        public FrontendSettings Frontend => new(configuration);
 36    }
 37}