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