-
Notifications
You must be signed in to change notification settings - Fork 62
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
Do not compare + segments unless wildcards in either accept or priority #94
Conversation
Fixes willdurand#93. If there are no wildcard segments in either the subtype or + segment of either the Accept header or priority, do not attempt to compare them. Adds more tests for willdurand#92 as well, using `*` subtypes in both the Accept header and priorities, to validate that different combinations work as expected.
@willdurand , @meyerbaptiste — ready to review! |
And @dunglas ! |
Our test suite is green with this patch (see api-platform/core#1104), thanks @weierophinney! |
src/Negotiation/Negotiator.php
Outdated
@@ -49,11 +49,17 @@ protected function match(AcceptHeader $accept, AcceptHeader $priority, $index) | |||
list($acceptSub, $acceptPlus) = $this->splitSubPart($acceptSub); | |||
list($prioritySub, $priorityPlus) = $this->splitSubPart($prioritySub); | |||
|
|||
// If no wildcards in either the subtype or + segment, do nothing. | |||
if (! ($acceptBase === '*' || $baseEqual) | |||
|| ! ($acceptSub === '*' || $prioritySub === '*' || $acceptPlus === '*' || $priorityPlus === '*')) { |
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.
According to PSR-2 when the if is multi-line the ) {
needs to be on it's own line.
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.
Surprised my linter didn't catch that! Fixing now and pushing momentarily. Also, for internal consistency, removing spaces following !
operators.
@willdurand do you think you'll soon have time soon to merge this patch and create a new release? It's currently breaking all API Platform projects when running |
doing this right now, was on holidays earlier this week.. |
Thanks everyone! ❤️ |
Fixes #93. If there are no wildcard segments in either the subtype or
+
segment of either the Accept header or priority, do not attempt to compare them.Adds more tests for #92 as well, using
*
subtypes in both the Accept header and priorities, to validate that different combinations work as expected.