mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: enforce file type filtering using tool's acceptedInputs
When registryEntry.accept is undefined, fall back to tool.acceptedInputs to derive the file filter. This ensures image tools reject audio/video files in the file picker, and vice versa.
This commit is contained in:
@@ -361,13 +361,13 @@ export function ToolPage() {
|
||||
setMobileSettingsOpen(false);
|
||||
}, [toolId]);
|
||||
|
||||
const toolAccept = registryEntry?.accept;
|
||||
const toolAccept = registryEntry?.accept ?? tool?.acceptedInputs?.join(",");
|
||||
const toolAcceptExts = useMemo(
|
||||
() => toolAccept?.split(",").map((e) => e.trim().replace(/^\./, "").toLowerCase()),
|
||||
[toolAccept],
|
||||
);
|
||||
const toolFileFilter = useMemo(() => {
|
||||
if (!toolAcceptExts) return undefined;
|
||||
if (!toolAcceptExts || toolAcceptExts.length === 0) return undefined;
|
||||
return (file: File) => {
|
||||
const ext = file.name.split(".").pop()?.toLowerCase() ?? "";
|
||||
return toolAcceptExts.includes(ext);
|
||||
|
||||
Reference in New Issue
Block a user