Skip to content

Commit

Permalink
fix(angular-apollo-tailwind): append protocol if missing from user url
Browse files Browse the repository at this point in the history
Refs: #591
  • Loading branch information
asincole committed Sep 16, 2022
1 parent f6a9578 commit 7a35b6b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h1 class="mt-2">
></hero-icon>
<a
class="link"
[href]="user.websiteUrl"
[href]="generateValidUrl(user.websiteUrl)"
target="_blank"
rel="noreferrer"
>
Expand All @@ -88,7 +88,7 @@ <h1 class="mt-2">
></sd-twitter-icon>
<a
class="link"
[href]="'https:/twitter.com/' + user.twitterUsername"
[href]="'https://twitter.com/' + user.twitterUsername"
target="_blank"
rel="noreferrer"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ export class ProfileAboutComponent implements OnInit {
}),
);
}

generateValidUrl(url: string) {
return ['http://', 'https://'].some((protocol) => url.startsWith(protocol))
? url
: `https://${url}`;
}
}

0 comments on commit 7a35b6b

Please sign in to comment.