Skip to content

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

1.7 KB
Raw Blame
import { describe, expect, test } from "bun:test";
import { PUBLIC_DEMO_INSTANCE_URL, normalizeInstanceUrl, resolveInstanceUrlInput } from "./public-demo.ts";

describe("public demo instance URL", () => {
  test("maps the App Review 'demo' alias to the public instance", () => {
    expect(PUBLIC_DEMO_INSTANCE_URL).toBe("https://demo.edgeever.org");
    expect(resolveInstanceUrlInput("demo")).toBe(PUBLIC_DEMO_INSTANCE_URL);
    expect(resolveInstanceUrlInput("DEMO")).toBe(PUBLIC_DEMO_INSTANCE_URL);
    expect(resolveInstanceUrlInput(" https://demo/ ")).toBe(PUBLIC_DEMO_INSTANCE_URL);
    expect(resolveInstanceUrlInput("http://demo")).toBe(PUBLIC_DEMO_INSTANCE_URL);
  });

  test("leaves real hosts unchanged", () => {
    expect(resolveInstanceUrlInput("https://demo.edgeever.org")).toBe("https://demo.edgeever.org");
    expect(resolveInstanceUrlInput("https://notes.example.com")).toBe("https://notes.example.com");
    expect(resolveInstanceUrlInput("demo.example.com")).toBe("demo.example.com");
    expect(resolveInstanceUrlInput("")).toBe("");
  });

  test("prefixes https when a host has no protocol", () => {
    expect(normalizeInstanceUrl("example.workers.dev")).toBe("https://example.workers.dev");
    expect(normalizeInstanceUrl(" example.workers.dev/ ")).toBe("https://example.workers.dev");
    expect(normalizeInstanceUrl("https://notes.example.com/")).toBe("https://notes.example.com");
    expect(normalizeInstanceUrl("http://127.0.0.1:8787")).toBe("http://127.0.0.1:8787");
    expect(normalizeInstanceUrl("ftp://example.com")).toBe("ftp://example.com");
    expect(normalizeInstanceUrl("demo")).toBe(PUBLIC_DEMO_INSTANCE_URL);
    expect(normalizeInstanceUrl("")).toBe("");
  });
});