Subtext.Framework.Format.UrlFormats.StripHostFromUrl C# (CSharp) Method

StripHostFromUrl() public static method

Return the url with the http://host stripped off the front. The given url may or maynot have the http://host on it.
public static StripHostFromUrl ( string url ) : string
url string
return string
        public static string StripHostFromUrl(string url)
        {
            string fullHost = string.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, Config.CurrentBlog.Host);

            if(url.StartsWith(fullHost))
            {
                // use Length b/c we want to leave the beginning "/" character on newUrl
                url = url.Substring(fullHost.Length);

                //Remove port number is present
                if (url.StartsWith(":"))
                {
                    int firstSlash = url.IndexOf('/');
                    url = url.Substring(firstSlash, url.Length - firstSlash);
                }
            }
            return url;
        }