Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoRedirect: Also handle relative location path correctly #52

Open
andreasld97 opened this issue Apr 27, 2023 · 0 comments
Open

AutoRedirect: Also handle relative location path correctly #52

andreasld97 opened this issue Apr 27, 2023 · 0 comments

Comments

@andreasld97
Copy link

andreasld97 commented Apr 27, 2023

Hi,

when using autoRedirect there is a problem with relative urls, because there are some feeds that
are using relative urls in the Location-Header since this is also valid:

https://www.tagesschau.de/xml/rss2/

The problem is that only AbsoluteUri will be used for the redirect:

So for relative urls an System.InvalidOperationException will be thrown here:

url = response.Headers?.Location?.AbsoluteUri ?? url;

(https://github.com/arminreiter/FeedReader/blob/master/FeedReader/Helpers.cs#L67-L76)

A fix for this problem could be done like this (I am not entirely sure if that is the correct way to get the absolute url though):

if (response.Headers?.Location?.IsAbsoluteUri == true)
{
    url = response.Headers?.Location?.AbsoluteUri;
}
else
{
    var uri = new Uri(url);
    url = uri.GetLeftPart(UriPartial.Authority) + response.Headers?.Location;           
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant