Browse Source

Fix bugs in verification badge code

master
buttercat1791 10 months ago
parent
commit
0c0c26a040
  1. 2
      src/lib/snippets/UserSnippets.svelte
  2. 7
      src/lib/utils/nostrUtils.ts

2
src/lib/snippets/UserSnippets.svelte

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<script lang='ts'>
<script module lang='ts'>
import { createProfileLink, createProfileLinkWithVerification } from '$lib/utils/nostrUtils';
export { userBadge };

7
src/lib/utils/nostrUtils.ts

@ -2,7 +2,7 @@ import { get } from 'svelte/store'; @@ -2,7 +2,7 @@ import { get } from 'svelte/store';
import { nip19 } from 'nostr-tools';
import { ndkInstance } from '$lib/ndk';
import { npubCache } from './npubCache';
import { NDKUser } from "@nostr-dev-kit/ndk";
import NDK, { NDKUser } from "@nostr-dev-kit/ndk";
const badgeCheckSvg = '<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 2c-.791 0-1.55.314-2.11.874l-.893.893a.985.985 0 0 1-.696.288H7.04A2.984 2.984 0 0 0 4.055 7.04v1.262a.986.986 0 0 1-.288.696l-.893.893a2.984 2.984 0 0 0 0 4.22l.893.893a.985.985 0 0 1 .288.696v1.262a2.984 2.984 0 0 0 2.984 2.984h1.262c.261 0 .512.104.696.288l.893.893a2.984 2.984 0 0 0 4.22 0l.893-.893a.985.985 0 0 1 .696-.288h1.262a2.984 2.984 0 0 0 2.984-2.984V15.7c0-.261.104-.512.288-.696l.893-.893a2.984 2.984 0 0 0 0-4.22l-.893-.893a.985.985 0 0 1-.288-.696V7.04a2.984 2.984 0 0 0-2.984-2.984h-1.262a.985.985 0 0 1-.696-.288l-.893-.893A2.984 2.984 0 0 0 12 2Zm3.683 7.73a1 1 0 1 0-1.414-1.413l-4.253 4.253-1.277-1.277a1 1 0 0 0-1.415 1.414l1.985 1.984a1 1 0 0 0 1.414 0l4.96-4.96Z" clip-rule="evenodd"/></svg>'
@ -115,6 +115,7 @@ export async function createProfileLinkWithVerification(identifier: string, disp @@ -115,6 +115,7 @@ export async function createProfileLinkWithVerification(identifier: string, disp
}
const cleanId = identifier.replace(/^nostr:/, '');
const escapedId = escapeHtml(cleanId);
const isNpub = cleanId.startsWith('npub');
let user: NDKUser;
@ -145,9 +146,9 @@ export async function createProfileLinkWithVerification(identifier: string, disp @@ -145,9 +146,9 @@ export async function createProfileLinkWithVerification(identifier: string, disp
const type = nip05.endsWith('edu') ? 'edu' : 'standard';
switch (type) {
case 'edu':
return `<span class="npub-badge">${graduationCapSvg}<a href="https://njump.me/${escapedId}" target="_blank">@${displayIdentifier}</a></span>`;
return `<span class="npub-badge"><a href="https://njump.me/${escapedId}" target="_blank">@${displayIdentifier}</a>${graduationCapSvg}</span>`;
case 'standard':
return `<span class="npub-badge">${badgeCheckSvg}<a href="https://njump.me/${escapedId}" target="_blank">@${displayIdentifier}</a></span>`;
return `<span class="npub-badge"><a href="https://njump.me/${escapedId}" target="_blank">@${displayIdentifier}</a>${badgeCheckSvg}</span>`;
}
}
/**

Loading…
Cancel
Save