Skip to content

Commit

Permalink
Add Uri fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMagnan committed Aug 23, 2022
1 parent dad07ba commit 08aae94
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/HtmlAgilityPack.Shared/HtmlWeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,20 @@ public async Task<HtmlDocument> 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)
{
Expand Down

0 comments on commit 08aae94

Please sign in to comment.