-
Notifications
You must be signed in to change notification settings - Fork 58
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
Ensure new_url
is absolute in Redirects
#391
Closed
JakubMastalerz
wants to merge
4
commits into
torchbox:main
from
JakubMastalerz:feature/consistent-redirect-urls
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change will have the effect of causing
newUrl
to always be absolute.Redirect.link
usesPage.url
in the case ofredirect_page
existing which will return a relative URL on single-site instances, or an absolute URL on multi-site instances. The reason your test is passing is that there are multiple sites. If we want to always return an absolute URL we should usePage.full_url
.Given the behaviour of
Page.url
(which seems like it shouldn't be problematic) I'm scratching my head a little as to why we're doing this. Unfortunately our ticket and my notes are a little vague as to the motivator. Is it worth making a change just for consistency of the format of the returned URL? Any thoughts @zerolab ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just got time to look at this properly.
Redirect.redirect_link
is an URLField and will always have a URL scheme and netloc (or at least it should), so this change doesn't improve the behaviour whatsoever.Looking at #384, the thought process was that
newUrl
should always be a full URL to reduce ambiguity in a multi-site setup. As far as I can unpick the results from #384 the relative URL comes from the fact that the redirect applies to all sites.Now, if we change to return full URLs, we should document it properly in the changelog and release notes. I am not opposed to always returning the full URL, but definitely want to have proper test coverage for redirect that apply to all sites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saying that, I do wonder if we're adding maintenance burden as we'll need to replicate https://github.com/wagtail/wagtail/blob/a09bba67cd58f519f3ae5bff32575e7ce9244031/wagtail/contrib/redirects/models.py#L68-L81
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can tell,
newUrl
being relative will only occur in single site setups, as we call intoPage.url
which returns relative URLs for single site, or an absolute URL if there are multiple sites. I'm having a hard time coming up with ways that this would be problematic. I think the original issue is erroneous.