diff --git a/README.md b/README.md index bd684c1..e27f05f 100644 --- a/README.md +++ b/README.md @@ -457,7 +457,7 @@ const config = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', - mastodon: '', + mastodon: 'arifszn@mastodon.social', facebook: '', instagram: '', dribbble: '', diff --git a/gitprofile.config.js b/gitprofile.config.js index 345721d..2c3598e 100644 --- a/gitprofile.config.js +++ b/gitprofile.config.js @@ -13,7 +13,7 @@ const config = { social: { linkedin: 'ariful-alam', twitter: 'arif_szn', - mastodon: '', + mastodon: 'arifszn@mastodon.social', facebook: '', instagram: '', dribbble: '', diff --git a/src/components/details/index.jsx b/src/components/details/index.jsx index a91f48c..d01e56d 100644 --- a/src/components/details/index.jsx +++ b/src/components/details/index.jsx @@ -31,22 +31,14 @@ const companyLink = (company) => { return `https://github.com/${company.substring(1)}`; }; -const getMastodonValue = (mastodonURL) => { - const regex = /(https?:\/\/)?(www\.)?([^\s/]+)\/@(\w+)/; +const getFormattedMastodonValue = (mastodonValue, isLink) => { + const [username, server] = mastodonValue.split('@'); - const match = mastodonURL.match(regex); - - if (match) { - const domain = match[3]; - const username = match[4]; - return `${domain}/@${username}`; + if (isLink) { + return `https://${server}/@${username}`; + } else { + return `${username}@${server}`; } - - return mastodonURL; -}; - -const getMastodonLink = (mastodonURL) => { - return mastodonURL.replace(/^(https?:\/\/)?(www\.)?/, 'https://'); }; const ListItem = ({ icon, title, value, link, skeleton = false }) => { @@ -136,8 +128,8 @@ const Details = ({ profile, loading, social, github }) => { } title="Mastodon:" - value={getMastodonValue(social.mastodon)} - link={getMastodonLink(social.mastodon)} + value={getFormattedMastodonValue(social.mastodon, false)} + link={getFormattedMastodonValue(social.mastodon, true)} /> )} {social?.linkedin && (