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