From 5de3d6bc92a3dce752dad2ce2acc17071383b6fa Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 21 Mar 2020 17:51:01 +0300 Subject: fix: bind link to developer name --- src/components/GithubAvatar/GithubAvatar.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/components') diff --git a/src/components/GithubAvatar/GithubAvatar.tsx b/src/components/GithubAvatar/GithubAvatar.tsx index 6aab28e..5daaac1 100644 --- a/src/components/GithubAvatar/GithubAvatar.tsx +++ b/src/components/GithubAvatar/GithubAvatar.tsx @@ -9,11 +9,14 @@ interface PropTypes { username: string; } +const githubUrl = 'https://github.com/'; +const getUserGithubUrl = (username: string) => githubUrl + username; + const GithubAvatar: React.FC = ({ username }) => { if (username === 'anonymous') return ; - const githubUrl = `https://github.com/${username}`; - const avatarUrl = githubUrl + '.png'; + const userGithubUrl = getUserGithubUrl(username); + const avatarUrl = userGithubUrl + '.png'; const usernameTokens = username.split(/[ ,.\-_#@;]/g); const altText = ( (usernameTokens.length > 1)? @@ -23,7 +26,7 @@ const GithubAvatar: React.FC = ({ username }) => { ).toUpperCase() return ( - + {altText} @@ -31,5 +34,6 @@ const GithubAvatar: React.FC = ({ username }) => { ) }; +export { getUserGithubUrl }; export default GithubAvatar; -- cgit v1.2.3