basant307/AI_Governance_Project
048
1// src/glossary.ts2var IS_PATCHED_MODULE = Symbol("isPatchedModule");3 4// src/utils/canParseUrl.ts5function canParseUrl(url) {6 try {7 new URL(url);8 return true;9 } catch (_error) {10 return false;11 }12}13 14// src/utils/getValueBySymbol.ts15function getValueBySymbol(symbolName, source) {16 const ownSymbols = Object.getOwnPropertySymbols(source);17 const symbol = ownSymbols.find((symbol2) => {18 return symbol2.description === symbolName;19 });20 if (symbol) {21 return Reflect.get(source, symbol);22 }23 return;24}25 26// src/utils/fetchUtils.ts27var _FetchResponse = class extends Response {28 static isConfigurableStatusCode(status) {29 return status >= 200 && status <= 599;30 }31 static isRedirectResponse(status) {32 return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);33 }34 /**35 * Returns a boolean indicating whether the given response status36 * code represents a response that can have a body.37 */38 static isResponseWithBody(status) {39 return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);40 }41 static setUrl(url, response) {42 if (!url || url === "about:" || !canParseUrl(url)) {43 return;44 }45 const state = getValueBySymbol("state", response);46 if (state) {47 state.urlList.push(new URL(url));48 } else {49 Object.defineProperty(response, "url", {50 value: url,51 enumerable: true,52 configurable: true,53 writable: false54 });55 }56 }57 /**58 * Parses the given raw HTTP headers into a Fetch API `Headers` instance.59 */60 static parseRawHeaders(rawHeaders) {61 const headers = new Headers();62 for (let line = 0; line < rawHeaders.length; line += 2) {63 headers.append(rawHeaders[line], rawHeaders[line + 1]);64 }65 return headers;66 }67 constructor(body, init = {}) {68 var _a;69 const status = (_a = init.status) != null ? _a : 200;70 const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;71 const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;72 super(finalBody, {73 status: safeStatus,74 statusText: init.statusText,75 headers: init.headers76 });77 if (status !== safeStatus) {78 const state = getValueBySymbol("state", this);79 if (state) {80 state.status = status;81 } else {82 Object.defineProperty(this, "status", {83 value: status,84 enumerable: true,85 configurable: true,86 writable: false87 });88 }89 }90 _FetchResponse.setUrl(init.url, this);91 }92};93var FetchResponse = _FetchResponse;94/**95 * Response status codes for responses that cannot have body.96 * @see https://fetch.spec.whatwg.org/#statuses97 */98FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];99FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];100 101// src/getRawRequest.ts102var kRawRequest = Symbol("kRawRequest");103function getRawRequest(request) {104 return Reflect.get(request, kRawRequest);105}106function setRawRequest(request, rawRequest) {107 Reflect.set(request, kRawRequest, rawRequest);108}109 110export {111 IS_PATCHED_MODULE,112 canParseUrl,113 FetchResponse,114 getRawRequest,115 setRawRequest116};117//# sourceMappingURL=chunk-3RXCRGL2.mjs.map