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

bug: 지원자의 프로토콜이 붙지 않은 포트폴리오 링크에 대한 버그 수정 #224

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
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
28 changes: 22 additions & 6 deletions frontend/components/applicant/applicantNode/Portfolio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Txt from "@/components/common/Txt.component";
import { ApplicantReq } from "@/src/apis/applicant";
import { applicantDataFinder } from "@/src/functions/finder";
import { changeIntactUrl } from "@/src/utils/applicant";
import Link from "next/link";

interface PortfolioProps {
Expand All @@ -12,15 +13,15 @@ const Portfolio = ({ data }: PortfolioProps) => {

const portfolio = applicantDataFinder(data, "portfolio")
.split(regex)
.map((url: string) => url.trim());
.map((url: string) => changeIntactUrl(url.trim()));

const file = applicantDataFinder(data, "fileUrl")
.split(regex)
.map((url: string) => url.trim());
.map((url: string) => changeIntactUrl(url.trim()));

const fileUrlForPlanner = applicantDataFinder(data, "fileUrlforPlanner")
.split(regex)
.map((url: string) => url.trim());
.map((url: string) => changeIntactUrl(url.trim()));

return (
<>
Expand All @@ -30,7 +31,12 @@ const Portfolio = ({ data }: PortfolioProps) => {
<Txt typography="h6">링크</Txt>
{portfolio.map((url: string, index: number) => {
return (
<Link href={url} target="_blank" key={index}>
<Link
href={url}
target="_blank"
rel="noopener noreferrer"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noopener noreferrer를 처음 알았네요..!
이런 디테일도 좋아보입니다

key={index}
>
<Txt className="break-all">{url}</Txt>
</Link>
);
Expand All @@ -40,7 +46,12 @@ const Portfolio = ({ data }: PortfolioProps) => {
<Txt typography="h6">파일</Txt>
{file.map((url: string, index: number) => {
return (
<Link href={url} target="_blank" key={index}>
<Link
href={url}
target="_blank"
rel="noopener noreferrer"
key={index}
>
<Txt className="break-all">{url}</Txt>
</Link>
);
Expand All @@ -51,7 +62,12 @@ const Portfolio = ({ data }: PortfolioProps) => {
<Txt typography="h6">이번 학기 프로젝트 기획서</Txt>
{fileUrlForPlanner.map((url: string, index: number) => {
return (
<Link href={url} target="_blank" key={index}>
<Link
href={url}
target="_blank"
rel="noopener noreferrer"
key={index}
>
<Txt className="break-all">{url}</Txt>
</Link>
);
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/utils/applicant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ export const findApplicantState = (
return cardsData.find((card) => card.applicantId === applicantId)?.state
.passState;
};

export const changeIntactUrl = (url: string) => {
if (!url) return url;

if (!/^https?:\/\//.test(url)) {
return `http://${url}`;
}

return url;
};