Rhythm.Staticize.UrlExtensions.GetParent C# (CSharp) Method

GetParent() public static method

获取URI的上一级的URI Address。
public static GetParent ( this uri ) : string
uri this
return string
        public static string GetParent(this Uri uri)
        {
            //input:http://xxx/xx.html
            //return:http://xxx
            String uriString = uri.ToString();
            int lastSlash = uriString.LastIndexOf('/');
            if (lastSlash == -1)
            {
                return uriString;
            }
            else
            {
                String baseDir = uriString.Substring(0, lastSlash + 1);
                return baseDir;//.TidyUri();
            }
        }