mirror of
https://github.com/xitanggg/open-resume
synced 2025-02-05 20:12:45 +01:00
Reformat link src logic
This commit is contained in:
parent
453e471f8b
commit
d29b899134
@ -56,34 +56,23 @@ 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 = "";
|
let src = "";
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "email":
|
case "email": {
|
||||||
urlSrc = `mailto:${value}`;
|
src = `mailto:${value}`;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case "phone":
|
case "phone": {
|
||||||
urlSrc = `tel:${value.replace(/[^\d+]/g, "")}`;
|
src = `tel:${value.replace(/[^\d+]/g, "")}`; // Keep only + and digits
|
||||||
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;
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
src = value.startsWith("http") ? value : `https://${value}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ResumePDFLink src={urlSrc} isPDF={isPDF}>
|
<ResumePDFLink src={src} isPDF={isPDF}>
|
||||||
{children}
|
{children}
|
||||||
</ResumePDFLink>
|
</ResumePDFLink>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user