-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
core-data: Fix canUser
allowed methods handling
#63615
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
headers: new Headers( { | ||
allow: 'POST', | ||
} ), |
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.
Headers
is the right interface for dealing with response headers. Just using the constructor adds the necessary functionality, including proper support for .get()
.
@@ -419,8 +419,7 @@ export const canUser = | |||
// Optional chaining operator is used here because the API requests don't | |||
// return the expected result in the native version. Instead, API requests | |||
// only return the result, without including response properties like the headers. | |||
const allowHeader = response.headers?.get( 'allow' ); | |||
const allowedMethods = allowHeader?.allow || allowHeader || ''; | |||
const allowedMethods = response.headers?.get( 'allow' ) || ''; |
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.
Cleaning up as the .allow
access was not necessary.
Size Change: -9 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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.
Thank you, @tyxla!
Interesting, so the In lodash, |
* core-data: Fix useResourcePermissions test fixtures * core-data: Clean up canUser allowed methods Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
This PR cleans up a wrong access for retrieving the allowed methods inside
canUser
.Why?
See #63430 (comment)
Because it's not necessary and was wrong. It was introduced in #43117 and the related test that needed to be improved was added in #38785.
How?
Fixing the test fixture and removing the unnecessary object access.
Testing Instructions
Testing Instructions for Keyboard
None
Screenshots or screencast
None