Skip to content

Commit 14fc030

Browse files
committed
Include protocol to homepage link if missing
Fixes velopert#153
1 parent 633b239 commit 14fc030

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)