fix: resolve audit findings — padding truncation, isNaN clarity, structuredClone#300
fix: resolve audit findings — padding truncation, isNaN clarity, structuredClone#300avoidwork wants to merge 5 commits into
Conversation
Implementation Audit ResultsGoal Fulfillment
Spec Compliance
Task Completion
Quality Check
|
🤖 Augment PR SummarySummary: This PR addresses audit findings around number formatting correctness and option cloning robustness. Changes:
Technical Notes: The new cloning path depends on runtime support for 🤖 Was this summary useful? React with 👍 or 👎 |
| symbols: JSON.parse(JSON.stringify(symbols)), | ||
| fullforms: JSON.parse(JSON.stringify(fullforms)), | ||
| localeOptions: | ||
| typeof structuredClone === "function" |
There was a problem hiding this comment.
src/filesize.js:L235: structuredClone() can throw (e.g., for functions or circular references) in Node 17+, which could turn previously-tolerated option objects into runtime errors. If users ever pass non-plain values in localeOptions/symbols/fullforms, this changes behavior compared to the prior JSON-clone approach.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| }); | ||
| }); | ||
|
|
||
| describe("partial structuredClone", () => { |
There was a problem hiding this comment.
tests/unit/filesize.test.js:L996: These "should use structuredClone" tests only validate immutability, so they’d still pass if the implementation reverted to JSON cloning. There also isn’t a test that exercises the fallback path when structuredClone is unavailable.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Summary
Fixes three audit findings in filesize.js: a medium-severity padding logic bug where excess decimal places are preserved when both separator and pad options are set, a low-severity isNaN clarity issue, and a low-severity JSON deep clone fragility in the partial function.
Type of Change
Related Issues
Fixes #296
Testing
Checklist
npm testpassesnpm run buildsucceedsScreenshots (if applicable)
N/A