refactor: 消除 es-toolkit/compat 依赖,isArray/isObject 替换为原生实现
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { isError } from "es-toolkit";
|
||||
import { isObject } from "es-toolkit/compat";
|
||||
|
||||
import type { CheckResult, RawTargetConfig } from "../../types";
|
||||
import type { CheckerContext, CheckerDefinition, CheckerValidationInput, ResolveContext } from "../types";
|
||||
@@ -161,7 +160,10 @@ function buildRedirectInit(init: RequestInit, statusCode: number, fromUrl: strin
|
||||
const method = init.method?.toUpperCase();
|
||||
|
||||
if (statusCode === 303 || ((statusCode === 301 || statusCode === 302) && method === "POST")) {
|
||||
const headers = isObject(init.headers) ? { ...(init.headers as Record<string, string>) } : undefined;
|
||||
const headers =
|
||||
typeof init.headers === "object" && init.headers !== null
|
||||
? { ...(init.headers as Record<string, string>) }
|
||||
: undefined;
|
||||
if (headers) {
|
||||
for (const key of Object.keys(headers)) {
|
||||
const lower = key.toLowerCase();
|
||||
@@ -176,7 +178,7 @@ function buildRedirectInit(init: RequestInit, statusCode: number, fromUrl: strin
|
||||
try {
|
||||
const fromOrigin = new URL(fromUrl).origin;
|
||||
const toOrigin = new URL(toUrl).origin;
|
||||
if (fromOrigin !== toOrigin && isObject(newInit.headers)) {
|
||||
if (fromOrigin !== toOrigin && typeof newInit.headers === "object" && newInit.headers !== null) {
|
||||
const headers = { ...(newInit.headers as Record<string, string>) };
|
||||
for (const key of Object.keys(headers)) {
|
||||
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
||||
|
||||
Reference in New Issue
Block a user