From 453e471f8bc016bb84c3f9df5ab87951ddd7f25b Mon Sep 17 00:00:00 2001 From: ShrootBuck Date: Mon, 3 Jul 2023 16:48:47 -0700 Subject: [PATCH] Add support for http(s) in visible text --- .../Resume/ResumePDF/ResumePDFProfile.tsx | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx b/src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx index aa8a44e..d697f03 100644 --- a/src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx +++ b/src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx @@ -56,31 +56,37 @@ export const ResumePDFProfile = ({ const Wrapper = ({ children }: { children: React.ReactNode }) => { if (!shouldUseLinkWrapper) return <>{children}; + let urlSrc = ""; + switch (key) { case "email": - return ( - - {children} - - ); + urlSrc = `mailto:${value}`; + break; case "phone": - return ( - - {children} - - ); + urlSrc = `tel:${value.replace(/[^\d+]/g, "")}`; + break; - default: - return ( - - {children} - - ); + case "url": + let removalCases = ["http://", "https://"]; + let http_protocol = "https://"; + + removalCases.forEach((item) => { + if (value.startsWith(item)) { + value = value.substring(item.length - 1, value.length - 1); + http_protocol = item; + } + }); + + urlSrc = `${http_protocol}${value}`; + break; } + + return ( + + {children} + + ); }; return (