From abe6d6e7aca187bf0330853da033cd7918b7b3c4 Mon Sep 17 00:00:00 2001 From: Ben Vinegar Date: Sat, 27 Jun 2026 09:33:21 -0400 Subject: [PATCH] chore(viewer): drop dead /u/ base-path fallback from default host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit createDefaultHost() derived its base path from `window.__SIDESHOW_BASE_PATH__ ?? location.pathname.match(/^\/u\/[^/]+/)?.[0] ?? ""`. The `/u/:account` URL-sniffing fallback was specific to an old hosted-wrapper URL shape — self-hosted sideshow runs at the root (empty base) or sets the global explicitly, and the current cloud wrapper injects its own host. So the regex branch was dead for every supported consumer. Derive the base path from the global alone, and refresh the now-stale `/u/alice` comment examples in host.ts and the embed type declarations. No behavior change for self-hosted (parity preserved). Co-Authored-By: Claude Opus 4.8 --- .changeset/drop-u-prefix-host-fallback.md | 10 ++++++++++ viewer/embed.d.ts | 2 +- viewer/src/host.ts | 11 +++++------ 3 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .changeset/drop-u-prefix-host-fallback.md diff --git a/.changeset/drop-u-prefix-host-fallback.md b/.changeset/drop-u-prefix-host-fallback.md new file mode 100644 index 0000000..659c711 --- /dev/null +++ b/.changeset/drop-u-prefix-host-fallback.md @@ -0,0 +1,10 @@ +--- +"sideshow": patch +--- + +Drop the dead `/u/`-prefix URL fallback from the default viewer host. The +embeddable engine's `createDefaultHost()` now derives its base path solely from +`window.__SIDESHOW_BASE_PATH__` (empty at root) instead of also sniffing a +`/u/:account` prefix out of `location.pathname`. That fallback was specific to an +old hosted-wrapper URL shape; self-hosted sideshow already runs at the root or +sets the global explicitly, so behavior is unchanged for every supported host. diff --git a/viewer/embed.d.ts b/viewer/embed.d.ts index 687bc35..0134cf1 100644 --- a/viewer/embed.d.ts +++ b/viewer/embed.d.ts @@ -14,7 +14,7 @@ export interface HostRouter { } export interface SideshowHost { - /** Link/base prefix the engine prepends to every path, e.g. "/u/alice" (""). */ + /** Link/base prefix the engine prepends to every path, e.g. "/alice" (""). */ basePath: string; router: HostRouter; /** The caller's own identity, when the host knows it. */ diff --git a/viewer/src/host.ts b/viewer/src/host.ts index fe118c6..241f0fa 100644 --- a/viewer/src/host.ts +++ b/viewer/src/host.ts @@ -23,7 +23,7 @@ export interface HostRouter { } export interface SideshowHost { - // Link/base prefix the engine prepends to every path, e.g. "/u/alice" ("" at + // Link/base prefix the engine prepends to every path, e.g. "/alice" ("" at // root). API calls are `${basePath}/api/...`. basePath: string; router: HostRouter; @@ -157,12 +157,11 @@ export function host(): SideshowHost { return (defaultHostCache ??= createDefaultHost()); } -// Self-hosted default host: base path from the hosted-wrapper global / URL -// prefix (as the pre-engine viewer read it), routing over the History API with -// URL shapes identical to before (/session/:id and /session/:id/s/:sid). +// Self-hosted default host: base path from the hosted-wrapper global (set by any +// wrapper before the engine loads; empty at root), routing over the History API +// with URL shapes identical to before (/session/:id and /session/:id/s/:sid). export function createDefaultHost(): SideshowHost { - const basePath = - window.__SIDESHOW_BASE_PATH__ ?? location.pathname.match(/^\/u\/[^/]+/)?.[0] ?? ""; + const basePath = window.__SIDESHOW_BASE_PATH__ ?? ""; const subs = new Set<(r: Route) => void>(); const get = (): Route => {