Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

861 B
Raw Blame
import { describe, expect, test } from "vitest";

import { getSafeAssistantHttpUrl } from "./assistant-url";

describe("getSafeAssistantHttpUrl", () => {
  test("allows ordinary HTTP and HTTPS source URLs", () => {
    expect(getSafeAssistantHttpUrl("https://example.com/source?q=homarr")).toBe("https://example.com/source?q=homarr");
    expect(getSafeAssistantHttpUrl("http://example.com/source")).toBe("http://example.com/source");
  });

  test("rejects unsafe protocols, relative URLs, and embedded credentials", () => {
    expect(getSafeAssistantHttpUrl("javascript:alert(1)")).toBeNull();
    expect(getSafeAssistantHttpUrl("data:text/html;base64,PGgxPkJhZDwvaDE+")).toBeNull();
    expect(getSafeAssistantHttpUrl("/manage/custom-widgets")).toBeNull();
    expect(getSafeAssistantHttpUrl("https://user:[email protected]/source")).toBeNull();
  });
});