Skip to content

Commit b37a002

Browse files
Handle non image file types in matchesAccept filter (#279)
* handle non image file types in matchesAccept filter * Create small-deer-tan.md --------- Co-authored-by: Hayden Bleasel <[email protected]>
1 parent 5fb2978 commit b37a002

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.changeset/small-deer-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"ai-elements": patch
3+
---
4+
5+
Handle non image file types in matchesAccept filter

packages/elements/src/prompt-input.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,11 +493,19 @@ export const PromptInput = ({
493493
if (!accept || accept.trim() === "") {
494494
return true;
495495
}
496-
if (accept.includes("image/*")) {
497-
return f.type.startsWith("image/");
498-
}
499-
// NOTE: keep simple; expand as needed
500-
return true;
496+
497+
const patterns = accept
498+
.split(",")
499+
.map((s) => s.trim())
500+
.filter(Boolean);
501+
502+
return patterns.some((pattern) => {
503+
if (pattern.endsWith("/*")) {
504+
const prefix = pattern.slice(0, -1); // e.g: image/* -> image/
505+
return f.type.startsWith(prefix);
506+
}
507+
return f.type === pattern;
508+
});
501509
},
502510
[accept]
503511
);

0 commit comments

Comments
 (0)