Skip to content

Commit

Permalink
fix(form): ensure file names end with a period for useFileUpload exte…
Browse files Browse the repository at this point in the history
…nsions
  • Loading branch information
mlaursen committed Sep 10, 2021
1 parent b2875b1 commit 9238140
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/form/src/file-input/__tests__/useFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ describe("useFileUpload", () => {
expect(input).toHaveAttribute("accept", ".svg,.png");

userEvent.upload(input, createFile("Invalid.txt", 1000));
userEvent.upload(input, createFile("Invalidpng", 1000));
userEvent.upload(input, createFile("Invalidsvg", 1000));

expect(readAsArrayBuffer).not.toBeCalled();

Expand Down
2 changes: 1 addition & 1 deletion packages/form/src/file-input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export function validateFiles<CustomError>(
const extraFiles: File[] = [];
const nameRegExp =
extensions.length > 0
? new RegExp(`.(${extensions.join("|")})$`, "i")
? new RegExp(`\\.(${extensions.join("|")})$`, "i")
: undefined;

let maxFilesReached = maxFiles > 0 && totalFiles >= maxFiles;
Expand Down

0 comments on commit 9238140

Please sign in to comment.