feat: rel=me for profile links, don't show http:// prefix

This commit is contained in:
Sam 2023-03-26 00:07:51 +01:00
parent 0c187aaf84
commit 256a14a922
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
3 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,21 @@
<script lang="ts">
import { Icon } from "sveltestrap";
export let link: string;
let displayLink: string;
$: displayLink = prettifyLink(link);
const prettifyLink = (raw: string) => {
let out = raw;
if (raw.startsWith("https://")) out = raw.substring("https://".length);
else if (raw.startsWith("http://")) out = raw.substring("http://".length);
if (raw.endsWith("/")) out = raw.substring(0, raw.length - 1);
return out;
};
</script>
<Icon name="globe" />
<a href={link} rel="me nofollow noreferrer" target="_blank">{displayLink}</a>