-
Notifications
You must be signed in to change notification settings - Fork 18
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
Match source and sourcehost case insensitively #63
Match source and sourcehost case insensitively #63
Conversation
@@ -49,7 +49,7 @@ public function getRouteCollectionForRequest(Request $request) | |||
} | |||
|
|||
$route = new Route( | |||
$redirectRoute->getSource(), | |||
$pathInfo, |
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.
@nnatter why this change?
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.
Is this the route name? Should we maybe more go with: 'sulu_redirect.redirect_' . $redirectRoute->getId()
or something 🤔
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.
no it is the path
of the route. this is used for generating the regex of the route here:
https://github.com/symfony/symfony/blob/252f85c2c249da7d8f2a490b57cc71199d51fcc9/src/Symfony/Component/Routing/RouteCompiler.php#L75-L92
it looks like the regex is evaluated case sensitive. if we pass /test123
here but the request contains TEST123
, symfony will not match the request to the route
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.
Okay this make sense not sure if we need to use here $pathInfo
or $request->getPathInfo
🤔
1acf7c9
to
04d6bdc
Compare
573762b
to
3994a2c
Compare
3994a2c
to
2adfae2
Compare
What's in this PR?
This PR adjusts the code to match the
source
andsourceHost
of a redirect in a case-insensitive manner.Assuming a redirect with
source: "redirect-url", sourceHost: "www.test.com"
:Behaviour before: matches only
www.test.com/redirect-url
Behaviour after: matches
www.test.com/redirect-url
,www.test.com/redirect-URL
,www.test.com/REDIRECT-url
, ...Why?
Because MySQL is case insensitive by default. This means it is not possible to create two redirects that use the same characters (eg. one redirect for
redirect-url
and one redirect forredirect-URL
).Because of this, without this change, it is not possible to redirect both urls (
www.test.com/redirect-url
andwww.test.com/redirect-URL
) at all.