Files
rea/src/domain/urlComponents.test.ts
Faheem Ahmad af29247a78 fix: honor empty URL query and fragment markers (#2091)
URL.search and URL.hash are empty for both a missing component and an explicit empty one, so endpoint and origin checks were accepting URLs the callers meant to reject.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-13 06:05:29 +09:00

23 lines
731 B
TypeScript

import { describe, expect, it } from "vitest";
import { urlDeclaresQueryOrFragment } from "./urlComponents.js";
describe("URL query and fragment spelling", () => {
it("treats an explicit empty query or fragment as present", () => {
expect(urlDeclaresQueryOrFragment(new URL("https://a.test/main.js"))).toBe(
false,
);
expect(
urlDeclaresQueryOrFragment(new URL("https://a.test/%3Ffile.js")),
).toBe(false);
for (const value of [
"https://a.test/main.js?",
"https://a.test/main.js#",
"https://a.test/main.js?#",
"https://a.test/main.js?v=1",
"https://a.test/main.js#part",
])
expect(urlDeclaresQueryOrFragment(new URL(value)), value).toBe(true);
});
});