ChiakiYu.Common.Web.WebHelper.FormatCompleteUrl C# (CSharp) Method

FormatCompleteUrl() public static method

把content中的虚拟路径转化成完整的url
例如: /abc/e.aspx 转化成 http://www.spacebuilder.cn/abc/e.aspx
public static FormatCompleteUrl ( string content ) : string
content string content
return string
        public static string FormatCompleteUrl(string content)
        {
            var srcPatternFormat = "src=[\"']\\s*(/[^\"']*)\\s*[\"']";
            var hrefPatternFormat = "href=[\"']\\s*(/[^\"']*)\\s*[\"']";

            var hostPath = HostPath(HttpContext.Current.Request.Url);

            content = Regex.Replace(content, srcPatternFormat, "src=\"" + hostPath + "$1\"",
                RegexOptions.IgnoreCase | RegexOptions.Compiled);
            content = Regex.Replace(content, hrefPatternFormat, "href=\"" + hostPath + "$1\"",
                RegexOptions.IgnoreCase | RegexOptions.Compiled);

            return content;
        }