Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Image sizes can read 1024 KB instead of 1.0 MB

Aperta Adatta ai principianti
#29 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
electron, react, typescript
Ambito
frontend, testing

Direzione di ricerca

Inizia da formatBytes in src/renderer/src/lib/format.ts e dai test esistenti in tests/format.test.ts. Aggiungi un describe('formatBytes') che copra i casi limite elencati, un valore semplice in B e 1.5 KB; esegui pnpm test. Il lavoro è concluso quando nessun output mostra 1024 di un’unità e i valori arrotondati a 10 o più non hanno decimali.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue

formatBytes picks the unit before rounding, so a size just under the next unit rounds up to 1024 of the smaller one. Image cards and the inspector use it for file sizes.

Bytes Shows now Should show
1048575 1024 KB 1.0 MB
1073741823 1024 MB 1.0 GB
10239 10.0 KB 10 KB
10240 10 KB 10 KB

The last two rows are the same problem one digit down: values that round to 10 or more are meant to drop the decimal, but 9.999 passes the >= 10 check before it's rounded.

Where to look
  • src/renderer/src/lib/format.ts: formatBytes
  • tests/format.test.ts: already imports from @renderer/lib/format, so add a describe('formatBytes') next to the hostOf tests

#12 asks for broader tests of this file and to leave bugs for separate pull requests. This is that separate fix, so it's fine to do either one first.

Done when
  • No size shows as 1024 of a unit, and anything that rounds to 10 or more has no decimal
  • Tests cover the rows above plus a plain B value and a 1.5 KB value, and pnpm test passes

Suggested pull request title: fix(shelf): show 1.0 MB instead of 1024 KB


New to OpenPaste? CONTRIBUTING.md covers setup, the code conventions and the checks to run before a pull request (pnpm typecheck, pnpm test, pnpm format, pnpm cleaner). Leave a comment if you're picking this up so nobody doubles up.


Generated by Claude Code

Lingua principale
TypeScript
Stelle
0
Fork
3
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alexsilver8/openpaste

Tutte le issue di alexsilver8/openpaste

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.