mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix account search
This commit is contained in:
parent
800e20a143
commit
c7a59b50d0
2 changed files with 27 additions and 10 deletions
18
src/utils/lookup.test.ts
Normal file
18
src/utils/lookup.test.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { assertEquals } from '@std/assert';
|
||||
|
||||
import { extractIdentifier } from './lookup.ts';
|
||||
|
||||
Deno.test('extractIdentifier', () => {
|
||||
assertEquals(
|
||||
extractIdentifier('https://njump.me/npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p'),
|
||||
'npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p',
|
||||
);
|
||||
assertEquals(
|
||||
extractIdentifier('npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p'),
|
||||
'npub1q3sle0kvfsehgsuexttt3ugjd8xdklxfwwkh559wxckmzddywnws6cd26p',
|
||||
);
|
||||
assertEquals(
|
||||
extractIdentifier('alex'),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { NIP05, NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||
import { NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import { match } from 'path-to-regexp';
|
||||
import tldts from 'tldts';
|
||||
|
||||
import { getAuthor } from '@/queries.ts';
|
||||
import { bech32ToPubkey } from '@/utils.ts';
|
||||
|
|
@ -27,14 +28,12 @@ export async function lookupPubkey(value: string, signal?: AbortSignal): Promise
|
|||
return bech32ToPubkey(value);
|
||||
}
|
||||
|
||||
if (NIP05.regex().test(value)) {
|
||||
try {
|
||||
const { pubkey } = await nip05Cache.fetch(value, { signal });
|
||||
return pubkey;
|
||||
} catch (e) {
|
||||
console.debug(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { pubkey } = await nip05Cache.fetch(value, { signal });
|
||||
return pubkey;
|
||||
} catch (e) {
|
||||
console.debug(e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ export function extractIdentifier(value: string): string | undefined {
|
|||
return value;
|
||||
}
|
||||
|
||||
if (NIP05.regex().test(value)) {
|
||||
if (tldts.parse(value).isIcann) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue