Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for Issue #20 where macOS 14+ screenshot filenames don't save because of narrow space #21

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,20 @@ export default class Dropzone extends Emitter {
}

// If @options.renameFile is a function,
// the function will be used to rename the file.name before appending it to the formData
// the function will be used to rename the file.name before appending it to the formData.
// MacOS 14+ screenshots contain narrow non-breaking space (U+202F) characters in filenames
// (e.g., "Screenshot 2024-01-30 at 10.32.07 AM.png" where the space after "07" and before "AM" is U+202F).
// This function now replaces these with regular spaces to prevent upload issues and maintain compatibility with MacOS
_renameFile(file) {
const cleanFile = {
...file,
name: file.name.replace(/\u202F/g, ' ')
};

if (typeof this.options.renameFile !== "function") {
return file.name;
return cleanFile.name;
}
return this.options.renameFile(file);
return this.options.renameFile(cleanFile);
}

// Returns a form that can be used as fallback if the browser does not support DragnDrop
Expand Down