Skip to content

Commit 73ae1b1

Browse files
authored
Merge pull request velopert#160 from velopert/fix/user-profile-home-link
Include protocol to homepage link if missing
2 parents 489fcc9 + 14fc030 commit 73ae1b1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/common/UserProfile.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ export interface UserProfileProps {
138138
username: string;
139139
}
140140

141+
function includeProtocol(address: string) {
142+
return /^https?:\/\//.test(address) ? address : `https://${address}`;
143+
}
144+
141145
const UserProfile: React.FC<UserProfileProps> = ({
142146
className,
143147
style,
@@ -211,7 +215,7 @@ const UserProfile: React.FC<UserProfileProps> = ({
211215
)}
212216
{url && (
213217
<a
214-
href={url}
218+
href={includeProtocol(url)}
215219
target="_blank"
216220
rel="noopener noreferrer"
217221
data-testid="facebook"

0 commit comments

Comments
 (0)