Skip to content

[Bug] fileExtension incorrect if file has no extension #857

Open
@aabenraa

Description

@aabenraa

Is there an existing issue for this?

  • I have searched the existing issues

Have you updated FilePond and its plugins?

  • I have updated FilePond and its plugins

Describe the bug

I'm finding that if I upload a file that has no extension (i.e., no "dot-something" at the end of the file name), when I use the fileExtension getter on the item, I get the full filename rather than an empty string. I'm working around it by comparing the results of fileExtension and filename, and if they're the same, proceed assuming there is actually is no extension.

Reproduction

I make a filepond instance like this:

const pond = FilePond.create(inputElement, {
  allowMultiple: true,
  instantUpload: true,
  allowRevert: true,
  allowRemove: false,
  allowReorder: true,
  dropOnPage: true,
  dropOnElement: false,
  maxParallelUploads: 10,
  server: {
    process: './do_file_upload.php',
    fetch: null,
    revert: './do_file_revert.php',
  }
});

then I catch the submit button click event for the form that the file input element is in, use pond.getfiles() to get the file list, and loop through looking at item.fileExtension among other things. If there is a file in the list without an extension, the results of item.filenameWithoutExtension and item.fileExtension are the same, and equal to the name of the uploaded file.

Environment

- Device: HP DL380 G8
- OS: Ubuntu 22.04.1 LTS
- Browser: Chrome 104.0.5112.101 on Win 10 19044.1889

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions