From 85ee616ff3c6c2a16476c9c21423b557b1adf292 Mon Sep 17 00:00:00 2001 From: Peyman Behin Aeinhamgini Date: Thu, 1 Jun 2023 17:14:36 +0200 Subject: [PATCH] Check if the location is relative. In dot net on Linux, Uri.TryCreate method for relative URL returns true (with UriKind.Absolute parameter) --- Abot2/Crawler/WebCrawler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Abot2/Crawler/WebCrawler.cs b/Abot2/Crawler/WebCrawler.cs index c74236d..802c3eb 100644 --- a/Abot2/Crawler/WebCrawler.cs +++ b/Abot2/Crawler/WebCrawler.cs @@ -929,7 +929,7 @@ protected virtual Uri ExtractRedirectUri(CrawledPage crawledPage) var location = crawledPage.HttpResponseMessage?.Headers?.Location?.ToString(); // Check if the location is absolute. If not, create an absolute uri. - if (!Uri.TryCreate(location, UriKind.Absolute, out locationUri)) + if (!Uri.TryCreate(location, UriKind.Absolute, out locationUri) || string.IsNullOrWhiteSpace(locationUri.Authority)) { var baseUri = new Uri(crawledPage.Uri.GetLeftPart(UriPartial.Authority)); locationUri = new Uri(baseUri, location);