Files
reverse-engineering-anything/src/domain/urlComponents.ts
T
Faheem AhmadandCursor 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

8 lines
358 B
TypeScript

/**
* True when the URL spells a query or fragment, including an empty one.
* `URL.search` and `URL.hash` are empty both when that component is absent
* and when it is present but empty, so href is the spelling that keeps them apart.
*/
export const urlDeclaresQueryOrFragment = (url: URL): boolean =>
url.href.includes("?") || url.href.includes("#");