feat: render relay description content

This commit is contained in:
codytseng 2026-01-19 22:07:53 +08:00
parent 0d6f8789d0
commit ee90ae99c1
3 changed files with 9 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import {
getImetaInfoFromImetaTag,
tagNameEquals
} from './tag'
import { randomString } from './random'
const EVENT_EMBEDDED_NOTES_CACHE = new LRUCache<string, string[]>({ max: 10000 })
const EVENT_EMBEDDED_PUBKEYS_CACHE = new LRUCache<string, string[]>({ max: 10000 })
@ -347,7 +348,7 @@ export function getReplaceableEventIdentifier(event: Event) {
export function createFakeEvent(event: Partial<Event>): Event {
return {
id: '',
id: randomString(64, { hex: true }),
kind: 1,
pubkey: '',
content: '',

View file

@ -1,9 +1,11 @@
const SEED = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
const HEX_SEED = 'abcdef0123456789'
export function randomString(len = 32) {
export function randomString(len = 32, { hex } = { hex: false }) {
let str = ''
const seed = hex ? HEX_SEED : SEED
for (let i = 0; i < len; i++) {
str += SEED[Math.floor(Math.random() * SEED.length)]
str += seed[Math.floor(Math.random() * SEED.length)]
}
return str
}