1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

try base domain if others fail

This commit is contained in:
Kyle Spearrin 2018-08-10 11:21:52 -04:00
parent 5f79af2e18
commit a564df42d6

View File

@ -64,12 +64,23 @@ namespace Bit.Icons.Services
uri = parsedHttpUri;
response = await GetAndFollowAsync(uri, 2);
if((response == null || !response.IsSuccessStatusCode) &&
Uri.TryCreate($"https://www.{parsedHttpsUri.Host}", UriKind.Absolute, out var parsedWwwUri))
if(response == null || !response.IsSuccessStatusCode)
{
Cleanup(response);
uri = parsedWwwUri;
response = await GetAndFollowAsync(uri, 2);
var dotCount = domain.Count(c => c == '.');
if(dotCount > 1 && DomainName.TryParseBaseDomain(domain, out var baseDomain) &&
Uri.TryCreate($"https://{baseDomain}", UriKind.Absolute, out var parsedBaseUri))
{
Cleanup(response);
uri = parsedBaseUri;
response = await GetAndFollowAsync(uri, 2);
}
else if(dotCount < 2 &&
Uri.TryCreate($"https://www.{parsedHttpsUri.Host}", UriKind.Absolute, out var parsedWwwUri))
{
Cleanup(response);
uri = parsedWwwUri;
response = await GetAndFollowAsync(uri, 2);
}
}
}