Filenames of imported files are truncated improperly when containing multiple periods

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

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Inizia in src/lib/file-uploader.js, all’interno di extractFileName, e riproduci l’upload con un nome file contenente più punti. Verifica che il nome dell’asset importato rimuova solo l’estensione finale, ad esempio importando image.jpg.png come image.jpg, e controlla i flussi di upload interessati per sprite, costumi, sfondi e suoni.

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

Descrizione

Expected Behavior

When a file is uploaded to Scratch (whether as a sprite, costume, backdrop, sound, etc.), only the file extension should be removed from the filename, if it exists.

Because a file's extension is determined by the contents of the filename after the last period, if a filename has multiple periods, only the last period (and the characters that follow) should be removed when uploaded.
e.g. An image with the filename image.jpg.png is treated as a PNG, and thus should be imported with the asset name image.jpg if the intention is to remove only the file extension when importing files to Scratch.

Actual Behavior

If a file with more than one period in its name is imported, the filename is truncated to the first period, not the last.
This leads to the filename being truncated before the actual file extension.

Based on the code responsible for this behavior and its comments, this code appears to be working as intended, but I am still reporting this as an issue on the basis of that intended behavior being undesirable from my perspective.

From file-uploader.js:

const extractFileName = function (nameExt) {
    // There could be multiple dots, but get the stuff before the first .
    const nameParts = nameExt.split('.', 1); // we only care about the first .
    return nameParts[0];
};
Steps to Reproduce

Steps to reproduce the behavior:

  1. Open the Scratch Editor (either via the Offline Editor or web browser)
  2. Click Upload Sprite, Upload Backdrop, Upload Costume, or Upload Sound.
  3. Select and upload a compatible file with more than one period in its filename.
System Details

Browser: Google Chrome 143.0.7499.170 (arm64)
Offline Editor: Version 3.31.1 (Downloaded from Mac App Store)
Operating System: macOS Tahoe 26.2

Screenshots

Original Filename: MAX.(period).png
Image
Expected Behavior: Uploaded as costume named MAX.(period)
Image
Actual Behavior: Uploaded as costume named MAX
Image

Lingua principale
JavaScript
Stelle
310
Fork
299
Merge medio
19h 41m
PR unite (30g)
14

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 scratchfoundation/scratch-editor

Tutte le issue di scratchfoundation/scratch-editor

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.