Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't require custom fetch options to not be in Request to pass them explicitly #542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/core/Ky.ts
Expand Up @@ -295,7 +295,7 @@ export class Ky {
}
}

const nonRequestOptions = findUnknownOptions(this.request, this._options);
const nonRequestOptions = findUnknownOptions(this._options);

if (this._options.timeout === false) {
return this._options.fetch(this.request.clone(), nonRequestOptions);
Expand Down
3 changes: 1 addition & 2 deletions source/utils/options.ts
@@ -1,13 +1,12 @@
import {kyOptionKeys, requestOptionsRegistry} from '../core/constants.js';

export const findUnknownOptions = (
request: Request,
options: Record<string, unknown>,
): Record<string, unknown> => {
const unknownOptions: Record<string, unknown> = {};

for (const key in options) {
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {
if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys)) {
unknownOptions[key] = options[key];
}
}
Expand Down