import { matchesDomain } from "../../../../libs/send-request/set-request-cookies.js";
//#region src/v2/blocks/operation-block/helpers/filter-global-cookies.ts
/**
* Filter a global cookie to determine if it should be included with a request to the given URL.
* - Returns false if the cookie is disabled, in the disabledGlobalCookies map, or missing a name.
* - Returns false if the domain does not match.
* - Returns false if the path is specified and does not match the URL pathname.
* - Returns true otherwise.
*/
var filterGlobalCookie = ({ cookie, url, disabledGlobalCookies }) => {
	if (cookie.isDisabled || disabledGlobalCookies[cookie.name.toLowerCase()] === true || !cookie.name) return false;
	const urlObject = new URL(url, "https://example.com");
	if (cookie.domain && !matchesDomain(url, cookie.domain)) return false;
	if (cookie.path && !urlObject.pathname.startsWith(cookie.path)) return false;
	return true;
};
//#endregion
export { filterGlobalCookie };

//# sourceMappingURL=filter-global-cookies.js.map