3public static class UrlCombine
11 public static string Combine(
string baseUrl,
string relativeUrl)
13 if (
string.IsNullOrWhiteSpace(baseUrl))
14 throw new ArgumentNullException(nameof(baseUrl));
16 if (
string.IsNullOrWhiteSpace(relativeUrl))
19 baseUrl = baseUrl.TrimEnd(
'/');
20 relativeUrl = relativeUrl.TrimStart(
'/');
22 return $
"{baseUrl}/{relativeUrl}";
31 public static string Combine(
string baseUrl, params
string[] relativePaths)
33 if (
string.IsNullOrWhiteSpace(baseUrl))
34 throw new ArgumentNullException(nameof(baseUrl));
36 if (relativePaths.Length == 0)
39 var currentUrl = Combine(baseUrl, relativePaths[0]);
41 return Combine(currentUrl, relativePaths.Skip(1).ToArray());