using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PushPlatform.Common.Util
{
    public class URLHelper
    {
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="urlConfig">url的配置名称</param>
        /// <returns></returns>
        public static string GetUrl(string urlConfig)
        {
            string isHttps = ConfigurationManager.AppSettings["IsHttps"];
            bool bIsHttps = string.IsNullOrEmpty(isHttps) ? false : Convert.ToBoolean(isHttps);

            string url = ConfigurationManager.AppSettings[urlConfig];
            if (bIsHttps && !string.IsNullOrEmpty(url))
                url = url.Replace("http://", "https://");
            
            return url;
        }
    }
}
