-
Notifications
You must be signed in to change notification settings - Fork 450
Expand file tree
/
Copy pathchunk-F7RG3QQH.js
More file actions
105 lines (97 loc) · 2.96 KB
/
chunk-F7RG3QQH.js
File metadata and controls
105 lines (97 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/glossary.ts
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
// src/utils/canParseUrl.ts
function canParseUrl(url) {
try {
new URL(url);
return true;
} catch (_error) {
return false;
}
}
// src/utils/getValueBySymbol.ts
function getValueBySymbol(symbolName, source) {
const ownSymbols = Object.getOwnPropertySymbols(source);
const symbol = ownSymbols.find((symbol2) => {
return symbol2.description === symbolName;
});
if (symbol) {
return Reflect.get(source, symbol);
}
return;
}
// src/utils/fetchUtils.ts
var _FetchResponse = class extends Response {
static isConfigurableStatusCode(status) {
return status >= 200 && status <= 599;
}
static isRedirectResponse(status) {
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
}
/**
* Returns a boolean indicating whether the given response status
* code represents a response that can have a body.
*/
static isResponseWithBody(status) {
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
}
static setUrl(url, response) {
if (!url || url === "about:" || !canParseUrl(url)) {
return;
}
const state = getValueBySymbol("state", response);
if (state) {
state.urlList.push(new URL(url));
} else {
Object.defineProperty(response, "url", {
value: url,
enumerable: true,
configurable: true,
writable: false
});
}
}
/**
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
*/
static parseRawHeaders(rawHeaders) {
const headers = new Headers();
for (let line = 0; line < rawHeaders.length; line += 2) {
headers.append(rawHeaders[line], rawHeaders[line + 1]);
}
return headers;
}
constructor(body, init = {}) {
var _a;
const status = (_a = init.status) != null ? _a : 200;
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
super(finalBody, {
...init,
status: safeStatus
});
if (status !== safeStatus) {
const state = getValueBySymbol("state", this);
if (state) {
state.status = status;
} else {
Object.defineProperty(this, "status", {
value: status,
enumerable: true,
configurable: true,
writable: false
});
}
}
_FetchResponse.setUrl(init.url, this);
}
};
var FetchResponse = _FetchResponse;
/**
* Response status codes for responses that cannot have body.
* @see https://fetch.spec.whatwg.org/#statuses
*/
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
exports.IS_PATCHED_MODULE = IS_PATCHED_MODULE; exports.canParseUrl = canParseUrl; exports.FetchResponse = FetchResponse;
//# sourceMappingURL=chunk-F7RG3QQH.js.map