You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
692 B
20 lines
692 B
import { describe, expect, test } from "bun:test";
|
|
import { assertSafeRssUrl, RssUrlUnsafeError } from "./rss-url";
|
|
|
|
describe("assertSafeRssUrl", () => {
|
|
test("allows https example", () => {
|
|
expect(() => assertSafeRssUrl("https://example.com/feed.xml")).not.toThrow();
|
|
});
|
|
|
|
test("rejects file protocol", () => {
|
|
expect(() => assertSafeRssUrl("file:///etc/passwd")).toThrow(RssUrlUnsafeError);
|
|
});
|
|
|
|
test("rejects localhost", () => {
|
|
expect(() => assertSafeRssUrl("http://localhost/feed")).toThrow(RssUrlUnsafeError);
|
|
});
|
|
|
|
test("rejects private ipv4 literal", () => {
|
|
expect(() => assertSafeRssUrl("http://192.168.1.1/feed")).toThrow(RssUrlUnsafeError);
|
|
});
|
|
});
|
|
|