// WHERE UMTOOL IS, for the editor's side of the clip finder (release 36, lane // A): `UMTOOL_URL`, trailing slashes dropped; null when unset. The video page // links to it and the find-clips job posts to its `/api/report/clips`. // // TEST-ONLY: E2E_UMTOOL_ORIGIN_FILE names a file holding ONE loopback origin // (`http://127.0.0.1:`). While that file exists, umtool is that origin — // the stub umtool an editor e2e spec starts (find-clips.spec) and names in the // file after the test server booted; it is read per call. Anything but a // loopback origin in it is ignored. Unset everywhere but the editor's e2e // server (the Bluesky fake's pattern, social/blueskyEndpoints.ts). import { readFileSync } from "node:fs"; const LOOPBACK_ORIGIN = /^http:\/\/(?:127\.0\.0\.1|localhost)(?::\d{1,5})?$/; export function umtoolUrl( env: Readonly> = process.env, ): string | null { const file = env.E2E_UMTOOL_ORIGIN_FILE; if (file) { let origin = ""; try { origin = readFileSync(file, "utf8").trim().replace(/\/+$/, ""); } catch { origin = ""; } if (LOOPBACK_ORIGIN.test(origin)) return origin; } const url = env.UMTOOL_URL?.trim().replace(/\/+$/, ""); return url ? url : null; }