nomadro/src/modules/social/lib/socialPath.ts
Eric 6e15868e04 Add isolated 游民社区 (/social) with social_svc and document test5.
Ship portal module + /api/social/v1 SQLite backend separate from /community; update README for MiroTalk CSP and test5 as the next development branch.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 11:24:21 +08:00

22 lines
613 B
TypeScript

/**
* Portal mounts 游民社区 under `/social`.
* Standalone deploy: set SOCIAL_BASE="" (or "/") so paths stay root-relative.
*/
export const SOCIAL_BASE = "/social";
export function socialPath(path = "/"): string {
if (!path || path === "/") return SOCIAL_BASE;
if (
path.startsWith("http://") ||
path.startsWith("https://") ||
path.startsWith("mailto:") ||
path.startsWith("tel:")
) {
return path;
}
if (path === SOCIAL_BASE || path.startsWith(`${SOCIAL_BASE}/`)) return path;
if (path.startsWith("/")) return `${SOCIAL_BASE}${path}`;
return `${SOCIAL_BASE}/${path}`;
}