fix: resolve logic bug and mutable default argument in getUserDataForFid - #553
Open
dajiaohuang wants to merge 1 commit into
Open
fix: resolve logic bug and mutable default argument in getUserDataForFid#553dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
- Remove redundant else branch that was overwriting acc[type] with the same value - Fix mutable default argument by creating requestOptions object fresh each time - Properly merge user-provided hubRequestOptions with default api_key header
|
@dajiaohuang is attempting to deploy a commit to the Discove Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
修复了
getUserDataForFid函数中的两个问题:Bug 1: 逻辑错误
原代码中 if/else 的两个分支执行完全相同的操作:
这会导致当找到的值更新时不会覆盖旧值,或者无论条件如何都覆盖。正确的逻辑应该是只在找到的值比当前值旧时才更新。
Bug 2: 可变默认参数
JavaScript 中使用可变对象作为默认参数是一个反模式,因为默认对象在所有调用中共享。原代码:
会在所有调用中共享同一个对象,如果调用者修改了它,会影响后续调用。
Fix