From 7711115f1e2a7f8cd73017d548274d4fab9f3d86 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 22 Nov 2026 21:01:33 -0700 Subject: A web address written without https:// is a link. "Amethyst is able to render that link as a link, but we don't. So can we?" (Adam, 2026-11-22, Saturday Bitcoin's rally post a6cea731: "Join the rally: saturdaybitcoin.com/rally/1?utm_source=nostr&utm_campaign=rally1-announce"). Only text starting http(s):// was a link, so a bare address stayed plain text. A name ending in a TLD people link to (.com, .org, .io, .co.uk, …), with an optional port and path, is now a link to its https:// address, shown as written, with trailing sentence punctuation left as text, and it gets a preview card like any other link. Never the domain of an email or nip05 (an @ before it), anything inside a longer URL, or names like node.js, app.py, README.md, e.g. New bare-link-test passes; relay-link, link-preview, post-markdown and features-smoke pass (markdown-note-test fails the same way without this change). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg --- tools/bare-link-test.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tools/bare-link-test.js (limited to 'tools/bare-link-test.js') diff --git a/tools/bare-link-test.js b/tools/bare-link-test.js new file mode 100644 index 0000000..71161af --- /dev/null +++ b/tools/bare-link-test.js @@ -0,0 +1,45 @@ +// A web address written without https:// ("saturdaybitcoin.com/rally/1?…") +// is a link, as Amethyst shows it; file names, emails and nip05s stay text. +// Run: bun tools/bare-link-test.js +import assert from 'node:assert/strict'; +import puppeteer from './puppeteer.js'; +import { finalizeEvent, generateSecretKey } from 'nostr-tools/pure'; +import { buildHtml, buildVerifyWorker } from '../build.js'; + +const sk = generateSecretKey(), now = Math.floor(Date.now() / 1000); +const note = finalizeEvent({ kind: 1, created_at: now, tags: [], content: 'Rally No. 1 is set.\n\nJoin the rally: saturdaybitcoin.com/rally/1?utm_source=nostr&utm_campaign=rally1-announce\n\nOr see example.org. Built with node.js, mail bob@gmail.com, I am _@coinos.io.' }, sk); +const profile = finalizeEvent({ kind: 0, created_at: now, tags: [], content: JSON.stringify({ name: 'Saturday Bitcoin' }) }, sk); +const html = await buildHtml({ minify: true, pwa: false }); +const worker = await buildVerifyWorker({ minify: true }); +const server = Bun.serve({ port: 0, fetch(req) { + const path = new URL(req.url).pathname; + if (path === '/api/feed') return Response.json({ version: 1, generatedAt: Date.now(), popUntil: now - 100, notes: [note], profiles: [profile] }); + if (path === '/verify-worker.js') return new Response(worker, { headers: { 'Content-Type': 'text/javascript' } }); + if (path.startsWith('/punks')) return new Response(null, { status: 404 }); + return new Response(html, { headers: { 'Content-Type': 'text/html' } }); +} }); +const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); +const check = (name, ok, detail = '') => { assert(ok, name + (detail ? ' — ' + detail : '')); console.log(' ✓ ' + name); }; +try { + const page = await browser.newPage(); + const errors = []; + page.on('pageerror', (e) => errors.push(e.message)); + await page.setRequestInterception(true); + page.on('request', (r) => (r.url().startsWith(server.url.origin) || r.url().startsWith('data:') ? r.continue() : r.abort())); + await page.goto(server.url.origin + '/feed'); + await page.waitForFunction(() => document.body.innerText.includes('Rally No. 1'), { timeout: 8000 }); + const links = await page.$$eval('.notes-feed .note-content a, .notes-feed a', (as) => [...new Set(as)].map((a) => ({ text: a.textContent, href: a.getAttribute('href') })).filter((a) => /^https:/.test(a.href || ''))); + const rally = links.find((a) => /saturdaybitcoin/.test(a.href)); + check('the bare address is a link', !!rally, JSON.stringify(links)); + check('...to its https address', rally.href === 'https://saturdaybitcoin.com/rally/1?utm_source=nostr&utm_campaign=rally1-announce', rally.href); + check('...shown as written', /^saturdaybitcoin\.com\/rally/.test(rally.text), rally.text); + const ex = links.find((a) => /example\.org/.test(a.href)); + check('a bare domain ending a sentence is a link without the full stop', ex && ex.href === 'https://example.org' && ex.text === 'example.org', JSON.stringify(ex)); + check('a file name, an email and a nip05 stay text', !links.some((a) => /node\.js|gmail|coinos/.test(a.href)), JSON.stringify(links)); + check('the text around them is intact', (await page.evaluate(() => document.querySelector('.notes-feed').innerText)).includes('example.org. Built with node.js, mail bob@gmail.com, I am _@coinos.io.')); + check('no page errors', !errors.length, errors.join(' | ')); + console.log('\n✅ bare web addresses are links'); +} finally { + await browser.close(); + server.stop(true); +} -- cgit v1.2.3