From 08aae949868908de457a77668a9489d73f0280b9 Mon Sep 17 00:00:00 2001 From: Jonathan Magnan Date: Tue, 23 Aug 2022 13:11:04 -0400 Subject: [PATCH] Add Uri fix --- src/HtmlAgilityPack.Shared/HtmlWeb.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/HtmlAgilityPack.Shared/HtmlWeb.cs b/src/HtmlAgilityPack.Shared/HtmlWeb.cs index e3268641..e8568044 100644 --- a/src/HtmlAgilityPack.Shared/HtmlWeb.cs +++ b/src/HtmlAgilityPack.Shared/HtmlWeb.cs @@ -2400,6 +2400,20 @@ public async Task LoadFromWebAsync(Uri uri, Encoding encoding, Net var e = await client.GetAsync(uri, cancellationToken).ConfigureAwait(false); _statusCode = e.StatusCode; + if(e.Headers != null && e.Headers.Location != null) + { + if(e.Headers.Location.IsAbsoluteUri) + { + _responseUri = new Uri(e.Headers.Location.AbsoluteUri); + } + else + { +#if !(NETSTANDARD1_3 || NETSTANDARD1_6 || WINDOWS_UWP) + _responseUri = new Uri(uri.GetLeftPart(UriPartial.Authority) + e.Headers.Location); +#endif + } + } + var html = string.Empty; if (encoding != null) {