BUGFIX: Compare hosts when checking if target and source are the same#106
Open
robinroloff wants to merge 1 commit intoneos:mainfrom
Open
BUGFIX: Compare hosts when checking if target and source are the same#106robinroloff wants to merge 1 commit intoneos:mainfrom
robinroloff wants to merge 1 commit intoneos:mainfrom
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes the "sameSourceAndTarget" and check. Previously, it was not correctly comparing the source and target host.
On the frontend, it was comparing the sourceHost to the host the user is currently on:
if (!host || host === location.host) {This also had the unwanted side effect that this check would only work when the user is creating a redirect for the very same domain they are currently on (most of the time the primary site). When they were creating a redirect for another site, this would only be checked on the backend and give the user a generic error "Redirect could not be created".
And on the backend, it was creating the redirect using the
$hostvariable:$redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($sourceUriPath, $host ?: null, false);and then comparing it against itself:
$isSame = $this->isSame($sourceUriPath, $targetUriPath, $host, $statusCode, $redirect);Example:
Domain: www.foo.bar
Source Path: test
Target Path: www.example.com/test
Before: This throws an error
Now: Works as expected