mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-12 10:08:49 +00:00
Compare commits
2 Commits
7a50d9328d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0235b490fa | ||
|
|
e290f98a86 |
@@ -219,6 +219,7 @@ export class AbstractRelay {
|
||||
const sub = this.subscribe(
|
||||
[{ ids: ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'], limit: 0 }],
|
||||
{
|
||||
label: 'forced-ping',
|
||||
oneose: () => {
|
||||
resolve(true)
|
||||
sub.close()
|
||||
|
||||
2
jsr.json
2
jsr.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nostr/tools",
|
||||
"version": "2.19.3",
|
||||
"version": "2.19.4",
|
||||
"exports": {
|
||||
".": "./index.ts",
|
||||
"./core": "./core.ts",
|
||||
|
||||
@@ -16,14 +16,14 @@ test('first: parse simple content with 1 url and 1 nostr uri', () => {
|
||||
})
|
||||
|
||||
test('second: parse content with 3 urls of different types', () => {
|
||||
const content = `:wss://oa.ao; this was a relay and now here's a video -> https://videos.com/video.mp4! and some music:
|
||||
const content = `:wss://oa.ao/a/; this was a relay and now here's a video -> https://videos.com/video.mp4! and some music:
|
||||
http://music.com/song.mp3
|
||||
and a regular link: https://regular.com/page?ok=true. and now a broken link: https://kjxkxk and a broken nostr ref: nostr:nevent1qqsr0f9w78uyy09qwmjt0kv63j4l7sxahq33725lqyyp79whlfjurwspz4mhxue69uhh56nzv34hxcfwv9ehw6nyddhq0ag9xg and a fake nostr ref: nostr:llll ok but finally https://ok.com!`
|
||||
const blocks = Array.from(parse(content))
|
||||
|
||||
expect(blocks).toEqual([
|
||||
{ type: 'text', text: ':' },
|
||||
{ type: 'relay', url: 'wss://oa.ao/' },
|
||||
{ type: 'relay', url: 'wss://oa.ao/a/' },
|
||||
{ type: 'text', text: "; this was a relay and now here's a video -> " },
|
||||
{ type: 'video', url: 'https://videos.com/video.mp4' },
|
||||
{ type: 'text', text: '! and some music:\n' },
|
||||
@@ -113,3 +113,18 @@ test('emoji shortcodes are treated as text if no event tags', () => {
|
||||
|
||||
expect(blocks).toEqual([{ type: 'text', text: 'hello :alpaca:' }])
|
||||
})
|
||||
|
||||
test("a thing that didn't work well in the wild", () => {
|
||||
const blocks = Array.from(
|
||||
parse(
|
||||
`Crowdsourcing doesn't mean just users clicking, by the way (although that could be possible too), it means a bunch of machines competing: https://leaderboard.sbstats.uk/`,
|
||||
),
|
||||
)
|
||||
expect(blocks).toEqual([
|
||||
{
|
||||
type: 'text',
|
||||
text: `Crowdsourcing doesn't mean just users clicking, by the way (although that could be possible too), it means a bunch of machines competing: `,
|
||||
},
|
||||
{ type: 'url', url: 'https://leaderboard.sbstats.uk/' },
|
||||
])
|
||||
})
|
||||
|
||||
2
nip27.ts
2
nip27.ts
@@ -41,7 +41,7 @@ export type Block =
|
||||
}
|
||||
|
||||
const noCharacter = /\W/m
|
||||
const noURLCharacter = /\W |\W$|$|,| /m
|
||||
const noURLCharacter = /[^\w\/] |[^\w\/]$|$|,| /m
|
||||
const MAX_HASHTAG_LENGTH = 42
|
||||
|
||||
export function* parse(content: string | NostrEvent): Iterable<Block> {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "module",
|
||||
"name": "nostr-tools",
|
||||
"version": "2.19.3",
|
||||
"version": "2.19.4",
|
||||
"description": "Tools for making a Nostr client.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user