mirror of
https://github.com/morluto/rea
synced 2026-10-28 15:07:26 -04:00
af29247a78
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>
23 lines
731 B
TypeScript
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);
|
|
});
|
|
});
|