diff options
Diffstat (limited to 'tools/link-preview-test.js')
| -rw-r--r-- | tools/link-preview-test.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/link-preview-test.js b/tools/link-preview-test.js index 2eeac7d..934c570 100644 --- a/tools/link-preview-test.js +++ b/tools/link-preview-test.js @@ -16,11 +16,14 @@ const AUTHOR = generateSecretKey(); const APK = getPublicKey(AUTHOR); const now = Math.floor(Date.now() / 1000); const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', 'base64'); const POSTS = [ - finalizeEvent({ kind: 1, created_at: now - 30, tags: [], content: 'Well, yeah https://news.example/story/1' }, AUTHOR), - finalizeEvent({ kind: 1, created_at: now - 60, tags: [], content: 'nothing here https://blank.example/page' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 30, tags: [], content: 'Well, yeah\n https://news.example/story/1 \nso there' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 60, tags: [], content: 'nothing here\nhttps://blank.example/page' }, AUTHOR), finalizeEvent({ kind: 1, created_at: now - 90, tags: [], content: 'a picture http://localhost:5311/pic.png' }, AUTHOR), - finalizeEvent({ kind: 1, created_at: now - 120, tags: [], content: 'film night https://paff.club/movie/1382-hackers-1995/play?q=1080p&t=4910' }, AUTHOR), - finalizeEvent({ kind: 1, created_at: now - 150, tags: [], content: 'on repeat https://paff.club/song/abc123' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 120, tags: [], content: 'film night\nhttps://paff.club/movie/1382-hackers-1995/play?q=1080p&t=4910' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 160, tags: [], content: 'can i make a PR on https://news.example/story/1 too' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 170, tags: [], content: 'is this it?\nhttps://news.example/story/1?' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 180, tags: [], content: 'see news.example/story/1.' }, AUTHOR), + finalizeEvent({ kind: 1, created_at: now - 150, tags: [], content: 'on repeat\n\nhttps://paff.club/song/abc123' }, AUTHOR), ]; const PROFILE = finalizeEvent({ kind: 0, created_at: now - 100, tags: [], content: JSON.stringify({ name: 'Linker', picture: 'http://localhost:5311/face.png', about: 'Read me at https://news.example/story/1 or https://paff.club/movie/1382-hackers-1995/play?q=1080p&t=4910' }) }, AUTHOR); @@ -138,6 +141,11 @@ try { check('...with the page\'s title', story?.title === 'Lawmakers doubt the plan', story?.title); check('...and its picture, already decoded', !!story?.thumb && story.thumbShown, JSON.stringify({ thumb: story?.thumb, shown: story?.thumbShown })); check('a page with nothing to show stays a bare link', !!blank && blank.bareLink && !blank.card, JSON.stringify(blank)); + // a link inside a sentence, or with punctuation after it, stays a link (Adam, 2026-12-05) + for (const [name, re] of [['mid-sentence', /make a PR on/], ['with a ? after it', /is this it/], ['bare, with a . after it', /^Linker.*see news/]]) { + const r = rows.find((x) => re.test(x.text)); + check('a link ' + name + ' stays a link, no card', !!r && !r.card, JSON.stringify(r)); + } check('a picture link is still a picture, not a card', !!pic && pic.img && !pic.card, JSON.stringify(pic)); // a PAFF film link plays in the post, PAFF's bare player loaded only on a tap const paff = await page.evaluate(() => { |
