fix: only run function inject for nostr entity
This commit is contained in:
@ -1,9 +1,11 @@
|
||||
interface Env {}
|
||||
|
||||
export const onRequest: PagesFunction<Env> = async context => {
|
||||
const id = context.params.id as string;
|
||||
const id = context.params.id as string | undefined;
|
||||
|
||||
const prefixes = ["npub1", "nprofile1", "naddr1", "nevent1", "note1"];
|
||||
const next = await context.next();
|
||||
if (id && prefixes.some(a => id.startsWith(a))) {
|
||||
try {
|
||||
const rsp = await fetch(
|
||||
`http://nostr.api.v0l.io/api/v1/opengraph/${id}?canonical=${encodeURIComponent("https://zap.stream/%s")}`,
|
||||
@ -30,5 +32,6 @@ export const onRequest: PagesFunction<Env> = async context => {
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return next;
|
||||
};
|
||||
|
Reference in New Issue
Block a user