85 lines
1.8 KiB
C#
85 lines
1.8 KiB
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
using UnityEngine.Scripting;
|
|
|
|
namespace UnityEngineInternal
|
|
{
|
|
// Token: 0x02000291 RID: 657
|
|
internal static class WebRequestUtils
|
|
{
|
|
// Token: 0x06002D0E RID: 11534 RVA: 0x0003FB74 File Offset: 0x0003DD74
|
|
[RequiredByNativeCode]
|
|
internal static string RedirectTo(string baseUri, string redirectUri)
|
|
{
|
|
Uri uri;
|
|
if (redirectUri[0] == '/')
|
|
{
|
|
uri = new Uri(redirectUri, UriKind.Relative);
|
|
}
|
|
else
|
|
{
|
|
uri = new Uri(redirectUri, UriKind.RelativeOrAbsolute);
|
|
}
|
|
string text;
|
|
if (uri.IsAbsoluteUri)
|
|
{
|
|
text = uri.AbsoluteUri;
|
|
}
|
|
else
|
|
{
|
|
Uri uri2 = new Uri(baseUri, UriKind.Absolute);
|
|
Uri uri3 = new Uri(uri2, uri);
|
|
text = uri3.AbsoluteUri;
|
|
}
|
|
return text;
|
|
}
|
|
|
|
// Token: 0x06002D0F RID: 11535 RVA: 0x0003FBDC File Offset: 0x0003DDDC
|
|
internal static string MakeInitialUrl(string targetUrl, string localUrl)
|
|
{
|
|
string text;
|
|
if (targetUrl.StartsWith("jar:file://"))
|
|
{
|
|
text = targetUrl;
|
|
}
|
|
else
|
|
{
|
|
Uri uri = new Uri(localUrl);
|
|
if (targetUrl.StartsWith("//"))
|
|
{
|
|
targetUrl = uri.Scheme + ":" + targetUrl;
|
|
}
|
|
if (targetUrl.StartsWith("/"))
|
|
{
|
|
targetUrl = uri.Scheme + "://" + uri.Host + targetUrl;
|
|
}
|
|
if (WebRequestUtils.domainRegex.IsMatch(targetUrl))
|
|
{
|
|
targetUrl = uri.Scheme + "://" + targetUrl;
|
|
}
|
|
Uri uri2 = null;
|
|
try
|
|
{
|
|
uri2 = new Uri(targetUrl);
|
|
}
|
|
catch (FormatException ex)
|
|
{
|
|
try
|
|
{
|
|
uri2 = new Uri(uri, targetUrl);
|
|
}
|
|
catch (FormatException)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
text = ((!targetUrl.Contains("%")) ? uri2.AbsoluteUri : uri2.OriginalString);
|
|
}
|
|
return text;
|
|
}
|
|
|
|
// Token: 0x040008A1 RID: 2209
|
|
private static Regex domainRegex = new Regex("^\\s*\\w+(?:\\.\\w+)+\\s*$");
|
|
}
|
|
}
|