Merge pull request #1426 from Kukks/fix-dead-link-tester

Fix dead link tester
This commit is contained in:
Andrew Camilleri 2020-04-04 14:21:22 +02:00 committed by GitHub
commit 238d4fceea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,16 +117,26 @@ namespace BTCPayServer.Tests
{
List<Task> checkLinks = new List<Task>();
var text = await File.ReadAllTextAsync(file);
var urlBlacklist = new string[]
{
"https://www.btse.com", // not allowing to be hit from circleci
"https://www.bitpay.com" // not allowing to be hit from circleci
};
foreach (var match in regex.Matches(text).OfType<Match>())
{
checkLinks.Add(AssertLinkNotDead(httpClient, match, file));
var url = match.Groups[1].Value;
if (urlBlacklist.Any(a => a.StartsWith(url.ToLowerInvariant())))
continue;
checkLinks.Add(AssertLinkNotDead(httpClient, url, file));
}
await Task.WhenAll(checkLinks);
}
private static async Task AssertLinkNotDead(HttpClient httpClient, Match match, string file)
private static async Task AssertLinkNotDead(HttpClient httpClient, string url, string file)
{
var url = match.Groups[1].Value;
try
{
using var request = new HttpRequestMessage(HttpMethod.Get, new Uri(url));