RuneStone 1.0.0

This commit is contained in:
Knotty Wyvern
2026-11-03 00:23:07 -07:00
commit 5557443ed1
818 changed files with 239368 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { loadFavicon } from '../src/favicon.mjs';
test('icons reject unsafe URLs and non-image responses, then use the next image', async () => {
const requested = [];
const icon = await loadFavicon(['file:///secret.png', 'javascript:alert(1)', 'https://example.com/bad', 'https://example.com/icon'], async url => {
requested.push(url);
return new Response('image', { headers: { 'content-type': url.endsWith('bad') ? 'text/html' : 'image/x-icon' } });
}, new AbortController().signal);
assert.deepEqual(requested, ['https://example.com/bad', 'https://example.com/icon']);
assert.equal(icon, 'data:image/x-icon;base64,aW1hZ2U=');
});
test('icons bound streamed data even without a content-length header', async () => {
const icon = await loadFavicon(['https://example.com/icon'], async () => new Response(new Uint8Array(65537), { headers: { 'content-type': 'image/png' } }), new AbortController().signal);
assert.equal(icon, null);
});
test('cancelled icon work does not make more requests', async () => {
const controller = new AbortController();
let calls = 0;
const icon = await loadFavicon(['https://example.com/one', 'https://example.com/two'], async () => {
calls++; controller.abort(); throw new Error('Aborted');
}, controller.signal);
assert.equal(icon, null);
assert.equal(calls, 1);
});