Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nixamp",
"version": "0.45.3",
"version": "0.45.4",
"description": "It really whips the terminal's ass. A Winamp-shaped audio player for your terminal.",
"license": "MIT",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function readConfig(): Config {
...(Array.isArray(record["guideHosts"]) ? { guideHosts: (record["guideHosts"] as unknown[]).filter((one): one is string => typeof one === "string") } : {}),
...(typeof record["guideAds"] === "object" && record["guideAds"] !== null ? { guideAds: record["guideAds"] as Config["guideAds"] } : {}),
...(Array.isArray(record["guidePeers"]) ? { guidePeers: (record["guidePeers"] as unknown[]).filter((one): one is string => typeof one === "string") } : {}),
...(typeof record["watchBase"] === "string" ? { watchBase: record["watchBase"] } : {}),
};
} catch {
return {};
Expand Down
17 changes: 16 additions & 1 deletion test/guide-rooms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { AddressInfo } from "node:net";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { handleRooms, RoomProbe, roomAddress, roomEntries, RoomStore, ROOMS_PER_MEMBER, watchPage } from "../src/guide-rooms.ts";
import { handleRooms, RoomProbe, roomAddress, roomEntries, RoomStore, ROOMS_PER_MEMBER, watchBase, watchPage } from "../src/guide-rooms.ts";
import { readConfig, writeConfig } from "../src/library.ts";
import { renderGuide } from "../src/station-guide.ts";

const PLAY = "https://server1.chovy.nixamp.com:4321/api/channels/folder-b19b85542264?k=JV5m_XbnQFD0K9_JEnGEXw";
Expand All @@ -25,6 +26,20 @@ test("a room address is a channel or the live stream, with a key and nothing els
]) assert.equal(roomAddress(bad), null, bad);
});

test("watchBase survives a config read, so the guide links rooms where it was told", () => {
const dir = mkdtempSync(join(tmpdir(), "rooms-config-"));
const saved = process.env["XDG_STATE_HOME"];
process.env["XDG_STATE_HOME"] = dir;
try {
writeConfig({ watchBase: "https://live.streaming.pit.world" });
assert.equal(readConfig().watchBase, "https://live.streaming.pit.world");
assert.equal(watchBase("https://fallback.example", {}), "https://live.streaming.pit.world");
} finally {
if (saved === undefined) delete process.env["XDG_STATE_HOME"]; else process.env["XDG_STATE_HOME"] = saved;
rmSync(dir, { recursive: true, force: true });
}
});

test("the room page carries the stream address", () => {
assert.equal(watchPage("https://live.streaming.pit.world", PLAY), `https://live.streaming.pit.world/watch?play=${encodeURIComponent(PLAY)}`);
});
Expand Down
Loading