From 9485d30f800ea913b6275b737e4ece39c674b46d Mon Sep 17 00:00:00 2001 From: Kelvin Del Monte Date: Fri, 27 Oct 2023 05:09:25 -0400 Subject: [PATCH] Fix an issue in firefox where the body option was being detected as an unknown option --- source/core/constants.ts | 17 +++++++++++++++++ source/utils/options.ts | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/source/core/constants.ts b/source/core/constants.ts index bbf43106..088ff58d 100644 --- a/source/core/constants.ts +++ b/source/core/constants.ts @@ -58,3 +58,20 @@ export const kyOptionKeys: KyOptionsRegistry = { onDownloadProgress: true, fetch: true, }; + +export const requestOptions = new Set([ + 'options', + 'method', + 'headers', + 'body', + 'mode', + 'credentials', + 'cache', + 'redirect', + 'referrer', + 'referrerPolicy', + 'integrity', + 'keepalive', + 'signal', + 'priority', +]); diff --git a/source/utils/options.ts b/source/utils/options.ts index 22c11d0a..95ae52cc 100644 --- a/source/utils/options.ts +++ b/source/utils/options.ts @@ -1,4 +1,4 @@ -import {kyOptionKeys} from '../core/constants.js'; +import {kyOptionKeys, requestOptions} from '../core/constants.js'; export const findUnknownOptions = ( request: Request, @@ -7,7 +7,7 @@ export const findUnknownOptions = ( const unknownOptions: Record = {}; for (const key in options) { - if (!(key in kyOptionKeys) && !(key in request)) { + if (!requestOptions.has(key) && !(key in kyOptionKeys) && !(key in request)) { unknownOptions[key] = options[key]; } }