diff --git a/src/components/Upload/UploadFile.tsx b/src/components/Upload/UploadFile.tsx index d8ef528..7228b56 100644 --- a/src/components/Upload/UploadFile.tsx +++ b/src/components/Upload/UploadFile.tsx @@ -55,6 +55,17 @@ type Action = error: string; }; +const getFileInfo = function (filename: string) { + if (filename.includes(".")) { + const parts = filename.split("."); + const extension = parts.pop(); + const name = parts.join("."); + return { filename: name, extension }; + } + + return { filename, extension: "" }; +}; + function reducer(state: State, action: Action) { switch (action.type) { case "progress": { @@ -243,9 +254,7 @@ export function UploadFile({ onClose(id); }; - const parts = file.name.split("."); - const extension = parts.pop(); - const filename = parts.join("."); + const { filename, extension } = getFileInfo(file.name); const { cid, error = "", preview, progress, status } = state; const onAction = state.status === "progress" ? onCancel : onInternalClose; const percent = @@ -277,7 +286,7 @@ export function UploadFile({ })} > {filename} - .{extension} + {extension && .{extension}}
{PrettyBytes(file.size)}