-
Notifications
You must be signed in to change notification settings - Fork 136
Description
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:
- Open the Scratch Editor (either via the Offline Editor or web browser)
- Click
Upload Sprite,Upload Backdrop,Upload Costume, orUpload Sound. - 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

Expected Behavior: Uploaded as costume named MAX.(period)

Actual Behavior: Uploaded as costume named MAX
