Skip to content

Commit

Permalink
Add support for extensions with numbers (eg mp3, woff2) (#6714)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlitus authored Nov 1, 2021
1 parent 0f80064 commit 5e61e00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-bulldogs-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-next/keystone": patch
---

When generating safe filenames, support extensions with numerical characters
4 changes: 2 additions & 2 deletions packages/keystone/src/lib/context/createFilesContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const generateSafeFilename = (
//
// This regex lazily matches for any characters that aren't a new line
// it then optionally matches the last instance of a "." symbol
// followed by any alphabetical character before the end of the string
const [, name, ext] = filename.match(/^([^:\n].*?)(\.[A-Za-z]+)?$/) as RegExpMatchArray;
// followed by any alphanumerical character before the end of the string
const [, name, ext] = filename.match(/^([^:\n].*?)(\.[A-Za-z0-9]+)?$/) as RegExpMatchArray;

const id = crypto
.randomBytes(24)
Expand Down

0 comments on commit 5e61e00

Please sign in to comment.