Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

995 B
Raw Blame
/** Public App Review / marketing demo. Never use a fake example host as the login placeholder. */
export const PUBLIC_DEMO_INSTANCE_URL = "https://demo.edgeever.org";

const publicDemoAliasHost = (value: string) =>
  value
    .trim()
    .replace(/\/+$/, "")
    .replace(/^https?:\/\//i, "")
    .toLowerCase();

/** Map the App Review typo "demo" (and https://demo) to the real public instance. */
export const resolveInstanceUrlInput = (value: string) => {
  const trimmed = value.trim();
  if (!trimmed) {
    return trimmed;
  }
  return publicDemoAliasHost(trimmed) === "demo" ? PUBLIC_DEMO_INSTANCE_URL : trimmed;
};

/** Resolve aliases, default missing schemes to https://, and drop trailing slashes. */
export const normalizeInstanceUrl = (value: string) => {
  const resolved = resolveInstanceUrlInput(value);
  if (!resolved) {
    return resolved;
  }
  const withProtocol = /:\/\//.test(resolved) ? resolved : `https://${resolved}`;
  return withProtocol.replace(/\/+$/, "");
};