1
mirror of https://github.com/xitanggg/open-resume synced 2024-11-03 09:19:21 +01:00

Add support for http(s) in visible text

This commit is contained in:
ShrootBuck 2023-07-03 16:48:47 -07:00 committed by Xitang Zhao
parent 0e5fe327fe
commit 453e471f8b

View File

@ -56,31 +56,37 @@ export const ResumePDFProfile = ({
const Wrapper = ({ children }: { children: React.ReactNode }) => {
if (!shouldUseLinkWrapper) return <>{children}</>;
let urlSrc = "";
switch (key) {
case "email":
return (
<ResumePDFLink src={`mailto:${value}`} isPDF={isPDF}>
{children}
</ResumePDFLink>
);
urlSrc = `mailto:${value}`;
break;
case "phone":
return (
<ResumePDFLink
src={`tel:${value.replace(/[\(\)\s-]/g, "")}`} // This regex "cleans" the number
isPDF={isPDF}
>
{children}
</ResumePDFLink>
);
urlSrc = `tel:${value.replace(/[^\d+]/g, "")}`;
break;
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;
}
default:
return (
<ResumePDFLink src={`https://${value}`} isPDF={isPDF}>
<ResumePDFLink src={urlSrc} isPDF={isPDF}>
{children}
</ResumePDFLink>
);
}
};
return (