Skip to content

Commit

Permalink
feat: add support for macos 14+ filenames (#21)
Browse files Browse the repository at this point in the history
fix #20
  • Loading branch information
brentmartinmiller authored Oct 29, 2024
1 parent fe5cfe3 commit a85a02f
Showing 1 changed file with 11 additions and 3 deletions.
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

0 comments on commit a85a02f

Please sign in to comment.