diff --git a/modules/rcal/components/folk-calendar-view.ts b/modules/rcal/components/folk-calendar-view.ts index 731541d..e94619b 100644 --- a/modules/rcal/components/folk-calendar-view.ts +++ b/modules/rcal/components/folk-calendar-view.ts @@ -354,8 +354,8 @@ class FolkCalendarView extends HTMLElement { private getApiBase(): string { // When on the rcal page directly, extract from URL - const match = window.location.pathname.match(/^\/([^/]+)\/rcal/); - if (match) return `/${match[1]}/rcal`; + const match = window.location.pathname.match(/^(\/[^/]+)?\/rcal/); + if (match) return match[0]; // When embedded as a canvas shape, use the space attribute if (this.space) return `/${this.space}/rcal`; return ""; diff --git a/modules/rcart/components/folk-cart-shop.ts b/modules/rcart/components/folk-cart-shop.ts index d1ff6ac..d3b95c1 100644 --- a/modules/rcart/components/folk-cart-shop.ts +++ b/modules/rcart/components/folk-cart-shop.ts @@ -184,8 +184,8 @@ class FolkCartShop extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const parts = path.split("/").filter(Boolean); - return parts.length >= 2 ? `/${parts[0]}/cart` : "/demo/cart"; + const match = path.match(/^(\/[^/]+)?\/rcart/); + return match ? match[0] : "/rcart"; } private async loadData() { diff --git a/modules/rchoices/components/folk-choices-dashboard.ts b/modules/rchoices/components/folk-choices-dashboard.ts index fe3e757..034656e 100644 --- a/modules/rchoices/components/folk-choices-dashboard.ts +++ b/modules/rchoices/components/folk-choices-dashboard.ts @@ -43,8 +43,8 @@ class FolkChoicesDashboard extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const parts = path.split("/").filter(Boolean); - return parts.length >= 2 ? `/${parts[0]}/choices` : "/demo/choices"; + const match = path.match(/^(\/[^/]+)?\/rchoices/); + return match ? match[0] : "/rchoices"; } private async loadChoices() { diff --git a/modules/rfiles/components/folk-file-browser.ts b/modules/rfiles/components/folk-file-browser.ts index 7fe4235..11c6ebc 100644 --- a/modules/rfiles/components/folk-file-browser.ts +++ b/modules/rfiles/components/folk-file-browser.ts @@ -161,8 +161,8 @@ class FolkFileBrowser extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/files/); - return match ? `/${match[1]}/files` : ""; + const match = path.match(/^(\/[^/]+)?\/rfiles/); + return match ? match[0] : ""; } private formatSize(bytes: number): string { diff --git a/modules/rforum/components/folk-forum-dashboard.ts b/modules/rforum/components/folk-forum-dashboard.ts index 2871573..778f2a7 100644 --- a/modules/rforum/components/folk-forum-dashboard.ts +++ b/modules/rforum/components/folk-forum-dashboard.ts @@ -43,8 +43,8 @@ class FolkForumDashboard extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/forum/); - return match ? `/${match[1]}/forum` : ""; + const match = path.match(/^(\/[^/]+)?\/rforum/); + return match ? match[0] : ""; } private getAuthHeaders(): Record { diff --git a/modules/rfunds/components/folk-funds-app.ts b/modules/rfunds/components/folk-funds-app.ts index 80820f6..de74c26 100644 --- a/modules/rfunds/components/folk-funds-app.ts +++ b/modules/rfunds/components/folk-funds-app.ts @@ -132,8 +132,9 @@ class FolkFundsApp extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/funds/); - return match ? `/${match[1]}/funds` : ""; + // Subdomain: /rfunds/... or Direct: /{space}/rfunds/... + const match = path.match(/^(\/[^/]+)?\/rfunds/); + return match ? `${match[0]}` : ""; } private async loadFlows() { @@ -221,7 +222,7 @@ class FolkFundsApp extends HTMLElement { // ─── Landing page ────────────────────────────────────── private renderLanding(): string { - const demoUrl = this.getApiBase() ? `${this.getApiBase().replace(/\/funds$/, "")}/funds/demo` : "/demo"; + const demoUrl = this.getApiBase() ? `${this.getApiBase()}/demo` : "/rfunds/demo"; const authed = isAuthenticated(); const username = getUsername(); @@ -325,8 +326,8 @@ class FolkFundsApp extends HTMLElement { private renderFlowCard(f: FlowSummary): string { const detailUrl = this.getApiBase() - ? `${this.getApiBase().replace(/\/funds$/, "")}/funds/flow/${encodeURIComponent(f.id)}` - : `/flow/${encodeURIComponent(f.id)}`; + ? `${this.getApiBase()}/flow/${encodeURIComponent(f.id)}` + : `/rfunds/flow/${encodeURIComponent(f.id)}`; const value = f.totalValue != null ? `$${Math.floor(f.totalValue).toLocaleString()}` : ""; return ` @@ -345,8 +346,8 @@ class FolkFundsApp extends HTMLElement { private renderDetail(): string { const backUrl = this.getApiBase() - ? `${this.getApiBase().replace(/\/funds$/, "")}/funds/` - : "/"; + ? `${this.getApiBase()}/` + : "/rfunds/"; return `
@@ -2268,8 +2269,8 @@ class FolkFundsApp extends HTMLElement { // Navigate to the new flow if (flowId) { const detailUrl = this.getApiBase() - ? `${this.getApiBase().replace(/\/funds$/, "")}/funds/flow/${encodeURIComponent(flowId)}` - : `/flow/${encodeURIComponent(flowId)}`; + ? `${this.getApiBase()}/flow/${encodeURIComponent(flowId)}` + : `/rfunds/flow/${encodeURIComponent(flowId)}`; window.location.href = detailUrl; return; } diff --git a/modules/rmaps/components/folk-map-viewer.ts b/modules/rmaps/components/folk-map-viewer.ts index 1861797..d6575fe 100644 --- a/modules/rmaps/components/folk-map-viewer.ts +++ b/modules/rmaps/components/folk-map-viewer.ts @@ -774,8 +774,8 @@ class FolkMapViewer extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/maps/); - return match ? `/${match[1]}/maps` : ""; + const match = path.match(/^(\/[^/]+)?\/rmaps/); + return match ? match[0] : ""; } private async checkSyncHealth() { diff --git a/modules/rnetwork/components/folk-graph-viewer.ts b/modules/rnetwork/components/folk-graph-viewer.ts index 2931a6c..961a1fa 100644 --- a/modules/rnetwork/components/folk-graph-viewer.ts +++ b/modules/rnetwork/components/folk-graph-viewer.ts @@ -107,8 +107,8 @@ class FolkGraphViewer extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/network/); - return match ? `/${match[1]}/network` : ""; + const match = path.match(/^(\/[^/]+)?\/rnetwork/); + return match ? match[0] : ""; } private async loadData() { diff --git a/modules/rnotes/components/folk-notes-app.ts b/modules/rnotes/components/folk-notes-app.ts index 83356e5..d80a5a7 100644 --- a/modules/rnotes/components/folk-notes-app.ts +++ b/modules/rnotes/components/folk-notes-app.ts @@ -633,8 +633,8 @@ Gear: EUR 400 (10%)

Maya is tracking expenses in rF private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/notes/); - return match ? `/${match[1]}/notes` : ""; + const match = path.match(/^(\/[^/]+)?\/rnotes/); + return match ? match[0] : ""; } private async loadNotebooks() { diff --git a/modules/rphotos/components/folk-photo-gallery.ts b/modules/rphotos/components/folk-photo-gallery.ts index c20c501..04bdc66 100644 --- a/modules/rphotos/components/folk-photo-gallery.ts +++ b/modules/rphotos/components/folk-photo-gallery.ts @@ -113,12 +113,12 @@ class FolkPhotoGallery extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/rphotos/); - return match ? `/${match[1]}/rphotos` : ""; + const match = path.match(/^(\/[^/]+)?\/rphotos/); + return match ? match[0] : ""; } private getImmichUrl(): string { - return `/${this.space}/rphotos/album`; + return `${this.getApiBase()}/album`; } private async loadGallery() { diff --git a/modules/rswag/components/folk-swag-designer.ts b/modules/rswag/components/folk-swag-designer.ts index 00b058f..781c134 100644 --- a/modules/rswag/components/folk-swag-designer.ts +++ b/modules/rswag/components/folk-swag-designer.ts @@ -184,8 +184,8 @@ class FolkSwagDesigner extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const parts = path.split("/").filter(Boolean); - return parts.length >= 2 ? `/${parts[0]}/swag` : "/demo/swag"; + const match = path.match(/^(\/[^/]+)?\/rswag/); + return match ? match[0] : "/rswag"; } private getDemoProduct(): DemoProduct { diff --git a/modules/rtrips/components/folk-route-planner.ts b/modules/rtrips/components/folk-route-planner.ts index 83d30d8..74ce80c 100644 --- a/modules/rtrips/components/folk-route-planner.ts +++ b/modules/rtrips/components/folk-route-planner.ts @@ -42,11 +42,8 @@ class FolkRoutePlanner extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const parts = path.split("/").filter(Boolean); - if (parts.length >= 2 && parts[1] === "trips") { - return `/${parts[0]}/trips`; - } - return "/demo/trips"; + const match = path.match(/^(\/[^/]+)?\/rtrips/); + return match ? match[0] : "/rtrips"; } private async fetchRoute(input: RouteInput): Promise { diff --git a/modules/rtrips/components/folk-trips-planner.ts b/modules/rtrips/components/folk-trips-planner.ts index 44df68f..ccb12cc 100644 --- a/modules/rtrips/components/folk-trips-planner.ts +++ b/modules/rtrips/components/folk-trips-planner.ts @@ -292,8 +292,8 @@ class FolkTripsPlanner extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/trips/); - return match ? `/${match[1]}/trips` : ""; + const match = path.match(/^(\/[^/]+)?\/rtrips/); + return match ? match[0] : ""; } private async loadTrips() { diff --git a/modules/rvote/components/folk-vote-dashboard.ts b/modules/rvote/components/folk-vote-dashboard.ts index 95207bf..645200c 100644 --- a/modules/rvote/components/folk-vote-dashboard.ts +++ b/modules/rvote/components/folk-vote-dashboard.ts @@ -133,8 +133,8 @@ class FolkVoteDashboard extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/vote/); - return match ? `/${match[1]}/vote` : ""; + const match = path.match(/^(\/[^/]+)?\/rvote/); + return match ? match[0] : ""; } private async loadSpaces() { diff --git a/modules/rwallet/components/folk-wallet-viewer.ts b/modules/rwallet/components/folk-wallet-viewer.ts index 6ab9a94..83495c4 100644 --- a/modules/rwallet/components/folk-wallet-viewer.ts +++ b/modules/rwallet/components/folk-wallet-viewer.ts @@ -86,8 +86,8 @@ class FolkWalletViewer extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/wallet/); - return match ? `/${match[1]}/wallet` : ""; + const match = path.match(/^(\/[^/]+)?\/rwallet/); + return match ? match[0] : ""; } private async detectChains() { diff --git a/modules/rwork/components/folk-work-board.ts b/modules/rwork/components/folk-work-board.ts index 477cdf1..5af32d1 100644 --- a/modules/rwork/components/folk-work-board.ts +++ b/modules/rwork/components/folk-work-board.ts @@ -56,8 +56,8 @@ class FolkWorkBoard extends HTMLElement { private getApiBase(): string { const path = window.location.pathname; - const match = path.match(/^\/([^/]+)\/work/); - return match ? `/${match[1]}/work` : ""; + const match = path.match(/^(\/[^/]+)?\/rwork/); + return match ? match[0] : ""; } private async loadWorkspaces() {