47 lines
1009 B
C#
47 lines
1009 B
C#
using System;
|
|
namespace SPSolutions.Web
|
|
{
|
|
public class HttpUtil
|
|
{
|
|
public static string BuildCustomUrlWithFallback(string customUrl, string baseUrl, string fallbackUrl)
|
|
{
|
|
string text = string.IsNullOrEmpty(customUrl) ? fallbackUrl : customUrl;
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
if (text.Contains("://"))
|
|
{
|
|
return text;
|
|
}
|
|
if (string.IsNullOrEmpty(baseUrl))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
string str = (!baseUrl.EndsWith("/")) ? baseUrl : baseUrl.Substring(0, baseUrl.Length - 1);
|
|
if (text.StartsWith("/"))
|
|
{
|
|
return str + text;
|
|
}
|
|
return str + "/" + text;
|
|
}
|
|
public static string AppendUrlQueryString(string url, string queryStringArgs)
|
|
{
|
|
if (string.IsNullOrEmpty(url))
|
|
{
|
|
return url;
|
|
}
|
|
int num = url.LastIndexOf("?");
|
|
if (num == -1)
|
|
{
|
|
return url + "?" + queryStringArgs;
|
|
}
|
|
if (num == url.Length - 1)
|
|
{
|
|
return url + queryStringArgs;
|
|
}
|
|
return url + "&" + queryStringArgs;
|
|
}
|
|
}
|
|
}
|