private static Uri GetUrl()

in src/Library/TelemetryGenerator.cs [581:613]


        private static Uri GetUrl(string scheme, string host, long port, string path)
        {
            if (string.IsNullOrEmpty(host))
            {
                return null;
            }

            string slash = string.Empty;
            if (!string.IsNullOrEmpty(path) && !path.StartsWith("/"))
            {
                slash = "/";
            }

            string url;
            if (port <= 0 || port == 80 || port == 443)
            {
                url = $"{scheme}://{host}{slash}{path}";
            }
            else
            {
                // host already has :port
                url = $"{scheme}://{host}{slash}{path}";
            }

            try
            {
                return new Uri(url);
            }
            catch (Exception e)
            {
                throw new FormatException($"url: {url}", e);
            }
        }