From ab2f69cd8aa5ffe4845a0626ae583f53ee83189a Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Mon, 16 Mar 2026 18:20:29 -0700 Subject: [PATCH] fix(canvas): use subdomain for space slug on *.rspace.online hosts The communitySlug derivation was parsing path segments (e.g. /rcal) as part of the space name instead of using the subdomain. On jeff.rspace.online/rcal, this caused communitySlug to be "rcal" instead of "jeff", making tab navigation redirect to rcal.rspace.online. Now: on subdomain hosts, space always comes from the subdomain. Path segments are only parsed for the space on localhost. Co-Authored-By: Claude Opus 4.6 --- website/canvas.html | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/website/canvas.html b/website/canvas.html index ccf5967..23705f8 100644 --- a/website/canvas.html +++ b/website/canvas.html @@ -2834,21 +2834,26 @@ const maxScale = 20; // Get community info from URL - // Supports path-based slugs: cca.rspace.online/campaign/demo → slug "campaign-demo" + // Subdomain pattern: {space}.rspace.online/{moduleId} → space = subdomain + // Localhost pattern: localhost/{space}/{moduleId} → space = first path segment const hostname = window.location.hostname; const subdomain = hostname.split(".")[0]; const isLocalhost = hostname === "localhost" || hostname === "127.0.0.1"; + const isSubdomainHost = !isLocalhost && hostname.endsWith(".rspace.online") && subdomain !== "www"; const urlParams = new URLSearchParams(window.location.search); - const pathSegments = window.location.pathname.split("/").filter(Boolean); - const ignorePaths = ["rspace", "canvas", "settings", "api"]; - const cleanSegments = pathSegments.filter(s => !ignorePaths.includes(s)); - let communitySlug = urlParams.get("space"); - if (!communitySlug && cleanSegments.length > 0) { - communitySlug = cleanSegments.join("-"); - } else if (!communitySlug) { - communitySlug = isLocalhost ? "demo" : subdomain; + if (!communitySlug) { + if (isSubdomainHost) { + // On {space}.rspace.online — subdomain IS the space, path is /{moduleId} + communitySlug = subdomain; + } else if (isLocalhost) { + // On localhost — path is /{space}/{moduleId} + const pathSegments = window.location.pathname.split("/").filter(Boolean); + communitySlug = pathSegments[0] || "demo"; + } else { + communitySlug = subdomain || "demo"; + } } // Update UI