Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Return an unexpected response if the redirect its the same that the original url #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bubudrc
Copy link

@bubudrc bubudrc commented Apr 10, 2023

I have an issue with an url (https://hipertextual.com/feed). Every time that I tried to get the articles, this endpoint redirects, several times to the same url.

This little update help to avoid the problem where the redirect url is the same that the original and returns an error.

@@ -104,10 +104,21 @@ extension DownloadSession: URLSessionTaskDelegate {

if response.statusCode == 301 || response.statusCode == 308 {
if let oldURLString = task.originalRequest?.url?.absoluteString, let newURLString = request.url?.absoluteString {
cacheRedirect(oldURLString, newURLString)
guard oldURLString != newURLString else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you rewrite this as if oldURLString == newURLString {? This would make it easier to understand for future people reading the code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants