Skip to content

fix: handle invalid byte sizes#13

Open
alibababye wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
alibababye:fix/format-sub-byte-values
Open

fix: handle invalid byte sizes#13
alibababye wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
alibababye:fix/format-sub-byte-values

Conversation

@alibababye

Copy link
Copy Markdown

Hi! I noticed formatBytes could render odd values for small or invalid artifact sizes.

For values between 0 and 1 byte, Math.log(bytes) made the unit index negative, which produced output like 512.0 undefined. Negative or non-finite values could also render as NaN undefined.

This PR guards invalid/non-positive values, clamps the selected unit, and adds a small Vitest regression test for the edge cases. I also added the missing Vitest setup file referenced by vite.config.ts, so the new frontend test can run with the existing test config.

Verified with:

npm install && npx vitest run src/lib/utils.test.ts
npm run build

Guard byte formatting against invalid and sub-byte values so the UI does not render NaN or undefined units.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant