mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-23 14:40:36 +01:00
Merge pull request #1426 from Kukks/fix-dead-link-tester
Fix dead link tester
This commit is contained in:
commit
238d4fceea
1 changed files with 13 additions and 3 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue