Compare commits

...

4 Commits

Author SHA1 Message Date
zhan c7f5e0136b
Merge 7580f476d1 into 23aebbd341 2025-08-28 09:49:40 +09:00
Anderson Juhasc 23aebbd341 update NIP-27 example in README 2025-08-27 10:32:45 -03:00
Anderson Juhasc a3fcd79545 ensures consistency for .jpg/.JPG, .mp4/.MP4, etc 2025-08-27 10:32:45 -03:00
zhan 7580f476d1
Update index.ts
export useWebSocketImplementation for nodejs
2024-07-15 11:16:05 +08:00
3 changed files with 6 additions and 20 deletions

View File

@ -169,8 +169,10 @@ for (let block of nip27.parse(evt.content)) {
case 'video':
case 'audio':
console.log("it's a media url:", block.url)
break
case 'relay':
console.log("it's a websocket url, probably a relay address:", block.url)
break
default:
break
}

View File

@ -1,5 +1,5 @@
export * from './pure.ts'
export { Relay } from './relay.ts'
export { Relay, useWebSocketImplementation } from './relay.ts'
export * from './filter.ts'
export { SimplePool } from './pool.ts'
export * from './references.ts'

View File

@ -90,35 +90,19 @@ export function* parse(content: string): Iterable<Block> {
yield { type: 'text', text: content.substring(prevIndex, u - prefixLen) }
}
if (
url.pathname.endsWith('.png') ||
url.pathname.endsWith('.jpg') ||
url.pathname.endsWith('.jpeg') ||
url.pathname.endsWith('.gif') ||
url.pathname.endsWith('.webp')
) {
if (/\.(png|jpe?g|gif|webp)$/i.test(url.pathname)) {
yield { type: 'image', url: url.toString() }
index = end
prevIndex = index
continue
}
if (
url.pathname.endsWith('.mp4') ||
url.pathname.endsWith('.avi') ||
url.pathname.endsWith('.webm') ||
url.pathname.endsWith('.mkv')
) {
if (/\.(mp4|avi|webm|mkv)$/i.test(url.pathname)) {
yield { type: 'video', url: url.toString() }
index = end
prevIndex = index
continue
}
if (
url.pathname.endsWith('.mp3') ||
url.pathname.endsWith('.aac') ||
url.pathname.endsWith('.ogg') ||
url.pathname.endsWith('.opus')
) {
if (/\.(mp3|aac|ogg|opus)$/i.test(url.pathname)) {
yield { type: 'audio', url: url.toString() }
index = end
prevIndex = index