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 <noreply@anthropic.com>
This commit is contained in:
parent
e42fa5c5d2
commit
ab2f69cd8a
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue