Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fileUrl에서 확장자명 추출 후 fileType 뒤에 삽입 #439 #440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/File/FileDownButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { buttonVariants } from '@/components/ui/button.tsx';
// 자료집 '/data'에 쓰이는 FileDownButton입니다.

export default function FileDownButton({ file, className }: { file: FileResponse; className?: string }) {
// fileUrl에서 확장자명을 추출한 후 대문자로 변경
const lastDotIndex = file.fileUrl.lastIndexOf('.');
const fileExtension = lastDotIndex !== -1 ? file.fileUrl.substring(lastDotIndex + 1) : '';
return (
<a
className={cn(
Expand All @@ -17,7 +20,7 @@ export default function FileDownButton({ file, className }: { file: FileResponse
href={file.fileUrl}
download={file.fileName}
>
{file.fileType}
{`${file.fileType} ${fileExtension.toUpperCase()}`}
</a>
);
}