Files
multica/packages/core/workspace/workspace-url.test.ts
Bohan Jiang 6f29a4c0a6 fix(workspace): derive workspace URL prefix from deployment host (MUL-3400) (#4286)
The create-workspace and onboarding UI hardcoded `multica.ai/` as the
workspace slug URL prefix, so self-hosted deployments showed the wrong
domain. Add a `workspaceUrlHost` helper that derives the host from the
deployment's app URL (`daemon_app_url` from `/api/config`, via the config
store) and falls back to the brand host when none is configured, then use
it in both views. Fixes #4263.

Co-authored-by: J <j@multica.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-06-18 11:12:10 +08:00

38 lines
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { workspaceUrlHost } from "./workspace-url";
describe("workspaceUrlHost", () => {
it("returns the host of a full app URL", () => {
expect(workspaceUrlHost("https://multica.example.com")).toBe(
"multica.example.com",
);
});
it("ignores scheme, path, and trailing slash", () => {
expect(workspaceUrlHost("https://multica.example.com/")).toBe(
"multica.example.com",
);
expect(workspaceUrlHost("http://multica.example.com/app/onboarding")).toBe(
"multica.example.com",
);
});
it("preserves a non-default port", () => {
expect(workspaceUrlHost("https://my.host:3000")).toBe("my.host:3000");
});
it("accepts a bare host without a scheme", () => {
expect(workspaceUrlHost("multica.example.com")).toBe("multica.example.com");
expect(workspaceUrlHost("multica.example.com/path")).toBe(
"multica.example.com",
);
});
it("falls back to the brand host when no app URL is configured", () => {
expect(workspaceUrlHost("")).toBe("multica.ai");
expect(workspaceUrlHost(" ")).toBe("multica.ai");
expect(workspaceUrlHost(null)).toBe("multica.ai");
expect(workspaceUrlHost(undefined)).toBe("multica.ai");
});
});