Skip to content

Commit b671480

Browse files
committedSep 2, 2022
Fix options.context being not extensible
Fixes #1077
1 parent 231f55d commit b671480

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
 

‎source/core/options.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,5 @@ export default class Options {
25212521
Object.freeze(options.retry.errorCodes);
25222522
Object.freeze(options.retry.methods);
25232523
Object.freeze(options.retry.statusCodes);
2524-
Object.freeze(options.context);
25252524
}
25262525
}

‎test/arguments.ts

+12
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,18 @@ test.failing('`context` option is enumerable', withServer, async (t, server, got
328328
});
329329
});
330330

331+
test('`context` option is never frozen', t => {
332+
const client = got.extend({
333+
context: {
334+
token: 'foobar',
335+
},
336+
});
337+
338+
client.defaults.options.context.token = '1234';
339+
340+
t.is(client.defaults.options.context.token, '1234');
341+
});
342+
331343
test('`context` option is accessible when using hooks', withServer, async (t, server) => {
332344
server.get('/', echoUrl);
333345

0 commit comments

Comments
 (0)
Please sign in to comment.