namespace HellionChat.Util;

internal static class UrlValidation
{
    // Used by BrandingLinks/IntegrationLinks at module init. A typo in a URL
    // rotation throws loudly at plugin load instead of silently failing when
    // a user clicks the broken button.
    public static void ValidateAll(string source, params string[] urls)
    {
        foreach (var url in urls)
        {
            if (
                !Uri.TryCreate(url, UriKind.Absolute, out var uri)
                || (uri.Scheme is not "https" and not "http")
            )
            {
                throw new InvalidOperationException($"{source} contains malformed URL: {url}");
            }
        }
    }
}
