/// <summary>Combines a two URLs</summary> /// <param name="baseUrl">The base URL</param> /// <param name="relativeUrl">The relative URL to add to the base URL</param> /// <returns>The absolute URL</returns> public static string Combine(string baseUrl, string relativeUrl) { if (baseUrl == null) { throw new ArgumentNullException(nameof(baseUrl), string.Format(Strings.Common_ArgumentIsNull, (object)nameof(baseUrl))); } if (relativeUrl == null) { throw new ArgumentNullException(nameof(relativeUrl), string.Format(Strings.Common_ArgumentIsNull, (object)nameof(relativeUrl))); } string str1 = UrlHelpers.ProcessBackSlashes(baseUrl); string str2 = UrlHelpers.ProcessBackSlashes(relativeUrl); string str3 = str1; if (str3.EndsWith("/")) { if (str2.StartsWith("/")) { str2 = str2.TrimStart('/'); } } else if (!str2.StartsWith("/")) { str3 += "/"; } return(UrlHelpers.Normalize(str3 + str2)); }
/// <summary>Gets a file name and extension of the specified URL</summary> /// <param name="url">URL</param> /// <returns>The consisting of the characters after the last directory character in URL</returns> public static string GetFileName(string url) { int num = url != null?UrlHelpers.FindLastDirectorySeparator(url) : throw new ArgumentNullException(nameof(url), string.Format(Strings.Common_ArgumentIsNull, (object)nameof(url))); return(num == -1 ? url : url.Substring(num + 1)); }