mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-10 17:18:51 +00:00
Compare commits
2 Commits
v2.18.0
...
d3ddd490c2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3ddd490c2 | ||
|
|
7730e321a5 |
@@ -107,3 +107,9 @@ test('parse content with hashtags and emoji shortcodes', () => {
|
|||||||
{ type: 'emoji', shortcode: 'star', url: 'https://example.com/star.png' },
|
{ type: 'emoji', shortcode: 'star', url: 'https://example.com/star.png' },
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('emoji shortcodes are treated as text if no event tags', () => {
|
||||||
|
const blocks = Array.from(parse('hello :alpaca:'))
|
||||||
|
|
||||||
|
expect(blocks).toEqual([{ type: 'text', text: 'hello :alpaca:' }])
|
||||||
|
})
|
||||||
|
|||||||
6
nip27.ts
6
nip27.ts
@@ -131,19 +131,19 @@ export function* parse(content: string | NostrEvent): Iterable<Block> {
|
|||||||
yield { type: 'text', text: content.slice(prevIndex, u - prefixLen) }
|
yield { type: 'text', text: content.slice(prevIndex, u - prefixLen) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/\.(png|jpe?g|gif|webp)$/i.test(url.pathname)) {
|
if (/\.(png|jpe?g|gif|webp|heic|svg)$/i.test(url.pathname)) {
|
||||||
yield { type: 'image', url: url.toString() }
|
yield { type: 'image', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
continue mainloop
|
continue mainloop
|
||||||
}
|
}
|
||||||
if (/\.(mp4|avi|webm|mkv)$/i.test(url.pathname)) {
|
if (/\.(mp4|avi|webm|mkv|mov)$/i.test(url.pathname)) {
|
||||||
yield { type: 'video', url: url.toString() }
|
yield { type: 'video', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
continue mainloop
|
continue mainloop
|
||||||
}
|
}
|
||||||
if (/\.(mp3|aac|ogg|opus)$/i.test(url.pathname)) {
|
if (/\.(mp3|aac|ogg|opus|wav|flac)$/i.test(url.pathname)) {
|
||||||
yield { type: 'audio', url: url.toString() }
|
yield { type: 'audio', url: url.toString() }
|
||||||
index = end
|
index = end
|
||||||
prevIndex = index
|
prevIndex = index
|
||||||
|
|||||||
Reference in New Issue
Block a user