Compare commits
4 Commits
46fea9519b
...
c7f5e0136b
Author | SHA1 | Date |
---|---|---|
|
c7f5e0136b | |
|
23aebbd341 | |
|
a3fcd79545 | |
|
7580f476d1 |
|
@ -169,8 +169,10 @@ for (let block of nip27.parse(evt.content)) {
|
||||||
case 'video':
|
case 'video':
|
||||||
case 'audio':
|
case 'audio':
|
||||||
console.log("it's a media url:", block.url)
|
console.log("it's a media url:", block.url)
|
||||||
|
break
|
||||||
case 'relay':
|
case 'relay':
|
||||||
console.log("it's a websocket url, probably a relay address:", block.url)
|
console.log("it's a websocket url, probably a relay address:", block.url)
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
2
index.ts
2
index.ts
|
@ -1,5 +1,5 @@
|
||||||
export * from './pure.ts'
|
export * from './pure.ts'
|
||||||
export { Relay } from './relay.ts'
|
export { Relay, useWebSocketImplementation } from './relay.ts'
|
||||||
export * from './filter.ts'
|
export * from './filter.ts'
|
||||||
export { SimplePool } from './pool.ts'
|
export { SimplePool } from './pool.ts'
|
||||||
export * from './references.ts'
|
export * from './references.ts'
|
||||||
|
|
22
nip27.ts
22
nip27.ts
|
@ -90,35 +90,19 @@ export function* parse(content: string): Iterable<Block> {
|
||||||
yield { type: 'text', text: content.substring(prevIndex, u - prefixLen) }
|
yield { type: 'text', text: content.substring(prevIndex, u - prefixLen) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (/\.(png|jpe?g|gif|webp)$/i.test(url.pathname)) {
|
||||||
url.pathname.endsWith('.png') ||
|
|
||||||
url.pathname.endsWith('.jpg') ||
|
|
||||||
url.pathname.endsWith('.jpeg') ||
|
|
||||||
url.pathname.endsWith('.gif') ||
|
|
||||||
url.pathname.endsWith('.webp')
|
|
||||||
) {
|
|
||||||
yield { type: 'image', url: url.toString() }
|
yield { type: 'image', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (
|
if (/\.(mp4|avi|webm|mkv)$/i.test(url.pathname)) {
|
||||||
url.pathname.endsWith('.mp4') ||
|
|
||||||
url.pathname.endsWith('.avi') ||
|
|
||||||
url.pathname.endsWith('.webm') ||
|
|
||||||
url.pathname.endsWith('.mkv')
|
|
||||||
) {
|
|
||||||
yield { type: 'video', url: url.toString() }
|
yield { type: 'video', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (
|
if (/\.(mp3|aac|ogg|opus)$/i.test(url.pathname)) {
|
||||||
url.pathname.endsWith('.mp3') ||
|
|
||||||
url.pathname.endsWith('.aac') ||
|
|
||||||
url.pathname.endsWith('.ogg') ||
|
|
||||||
url.pathname.endsWith('.opus')
|
|
||||||
) {
|
|
||||||
yield { type: 'audio', url: url.toString() }
|
yield { type: 'audio', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
|
|
Loading…
Reference in New Issue