hdsdump.f4m.URL.normalizeRelativeURL(string)

Here are the examples of the csharp api class hdsdump.f4m.URL.normalizeRelativeURL(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

Project: hdsdump
Source File: URL.cs
public static string normalizePathForURL(string url, bool removeFilePart) {
            if (string.IsNullOrEmpty(url))
                return string.Empty;
            string result = url;
            System.Uri uri = new System.Uri(url);
            if (uri.IsAbsoluteUri) {
                result = uri.Scheme + "://" + uri.Host;
                if (((uri.Scheme=="http") && (uri.Port!=80)) || ((uri.Scheme == "https") && (uri.Port != 443))) {
                    result += ":" + uri.Port;
                }
                string path = uri.LocalPath;
                if (path != null && path.Length > 0) {
                    if (removeFilePart) {
                        int index = path.LastIndexOf("/");
                        if (index >= 0)
                            path = path.Substring(0, index+1);
                    }
                    if ((path.Length > 0) && (path[0]=='/')) {
                        result += path;
                    } else {
                        result += "/" + normalizeRelativeURL(path);
                    }
                }
            }
            return normalizeRootURL(result);
        }