@dongdev/fca-unofficial 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/src/utils/headers.js +22 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/utils/headers.js
CHANGED
|
@@ -34,7 +34,28 @@ function getHeaders(url, options, ctx, customHeader) {
|
|
|
34
34
|
"Cache-Control": "no-cache"
|
|
35
35
|
};
|
|
36
36
|
if (ctx?.region) headers["X-MSGR-Region"] = ctx.region;
|
|
37
|
-
if (customHeader && typeof customHeader === "object")
|
|
37
|
+
if (customHeader && typeof customHeader === "object") {
|
|
38
|
+
// Filter customHeader to only include valid HTTP header values (strings, numbers, booleans)
|
|
39
|
+
// Exclude functions, objects, arrays, and other non-serializable values
|
|
40
|
+
for (const [key, value] of Object.entries(customHeader)) {
|
|
41
|
+
// Skip null, undefined, functions, objects, and arrays
|
|
42
|
+
if (value === null || value === undefined || typeof value === "function") {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "object") {
|
|
46
|
+
// Arrays are objects in JavaScript, so check for arrays explicitly
|
|
47
|
+
if (Array.isArray(value)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Skip plain objects (but allow null which is already handled above)
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// Only allow strings, numbers, and booleans - convert to string
|
|
54
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
55
|
+
headers[key] = String(value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
38
59
|
return headers;
|
|
39
60
|
}
|
|
40
61
|
|