mirror of
https://github.com/yusufipk/YTChatHub.git
synced 2026-09-11 10:56:17 +00:00
Backend: one SSE stream for messages, selection, poll and connection status; reconnect with backoff; no on-disk Innertube session cache; mock only with MOCK_CHAT=1; binds to 127.0.0.1; serves client/out so production runs on one port. Full URLs for links YouTube truncates in chat. Client: components split out, Lucide icons, stream title and status, on-air strip, search, pause, keyboard shortcuts, overlay settings dialog. Overlay themes, position, size, animation and auto-hide via URL, sized for 1080p and scaled with the source. New blueprint theme for the brand background. Removed Tailwind, better-sqlite3, zod, the timezone helpers, Cline memory bank and AGENTS.md. Added ESLint, node:test tests and CI.
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { extractLiveId } from './liveId';
|
|
|
|
const ID = 'dQw4w9WgXcQ';
|
|
|
|
test('bare id', () => {
|
|
assert.equal(extractLiveId(ID), ID);
|
|
assert.equal(extractLiveId(` ${ID}\n`), ID);
|
|
});
|
|
|
|
test('watch URLs', () => {
|
|
assert.equal(extractLiveId(`https://www.youtube.com/watch?v=${ID}`), ID);
|
|
assert.equal(extractLiveId(`https://www.youtube.com/watch?v=${ID}&t=42s&feature=share`), ID);
|
|
assert.equal(extractLiveId(`https://m.youtube.com/watch?feature=share&v=${ID}`), ID);
|
|
assert.equal(extractLiveId(`youtube.com/watch?v=${ID}`), ID);
|
|
});
|
|
|
|
test('short and live URLs', () => {
|
|
assert.equal(extractLiveId(`https://youtu.be/${ID}`), ID);
|
|
assert.equal(extractLiveId(`https://youtu.be/${ID}?si=abc123`), ID);
|
|
assert.equal(extractLiveId(`https://www.youtube.com/live/${ID}`), ID);
|
|
assert.equal(extractLiveId(`https://www.youtube.com/live/${ID}?feature=share`), ID);
|
|
assert.equal(extractLiveId(`https://www.youtube.com/embed/${ID}`), ID);
|
|
});
|
|
|
|
test('junk', () => {
|
|
assert.equal(extractLiveId(undefined), '');
|
|
assert.equal(extractLiveId(''), '');
|
|
assert.equal(extractLiveId('hello world'), '');
|
|
assert.equal(extractLiveId('dQw4w9WgXc'), '');
|
|
assert.equal(extractLiveId('https://www.youtube.com/'), '');
|
|
assert.equal(extractLiveId('https://www.youtube.com/watch?v=short'), '');
|
|
assert.equal(extractLiveId(`https://example.com/${ID}`), '');
|
|
assert.equal(extractLiveId('http://[bad'), '');
|
|
});
|