-
-
Notifications
You must be signed in to change notification settings - Fork 116
fix: #382 prevent network calls for the falsy/undefined src values inside isImageValid #383
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
Conversation
…d src values inside isImageValid
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough在 Changes
Sequence Diagram(s)sequenceDiagram
participant C as 客户端
participant F as isImageValid 函数
C->>F: 调用 isImageValid(src)
alt src 为 falsy
F->>C: 返回 false (提前终止)
else src 有效
F->>F: 创建图片对象并加载 src
F->>C: 返回加载结果
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
src/util.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/util.ts (1)
3-6: 这个修改很好,可以避免不必要的网络请求!新增的代码可以防止当
src参数为falsy值(如null、undefined或空字符串)时进行不必要的网络调用,从而提高性能和稳定性。这正确地解决了PR中提到的问题。不过,函数签名显示
src参数期望类型为string,但实际上函数现在处理的是包括falsy值在内的情况。考虑更新函数签名以明确允许这些情况,例如:src: string | null | undefined。- export function isImageValid(src: string) { + export function isImageValid(src: string | null | undefined) {
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #383 +/- ##
=======================================
Coverage 99.39% 99.40%
=======================================
Files 17 17
Lines 499 502 +3
Branches 147 148 +1
=======================================
+ Hits 496 499 +3
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Issue: [Bug] A bunch of image requests to undefined
close #382
Summary by CodeRabbit