namespace QYZH.InteractiveMagazine.Common.Helpers
{
    public static class DomainHelper
    {
        public static string OssDomain { get; set; }

        public static string VodDomain { get; set; }

        public static string OssFullUrl(string url) => GetFullUrl(url, OssDomain);

        public static string VodFullUrl(string url) => GetFullUrl(url, VodDomain);

        private static string GetFullUrl(string url, string domain)
        {
            if (string.IsNullOrWhiteSpace(url)) return string.Empty;

            if (url.StartsWith("http")) return url;

            // 确保域名末尾没有斜杠，url开头有斜杠
            var cleanDomain = domain.TrimEnd('/');
            var cleanUrl = url.StartsWith("/") ? url : "/" + url;

            return $"{cleanDomain}{cleanUrl}";
        }
    }
}
