Got: New options `https` are not merged when extend()

Created on 5 Jun 2020  路  3Comments  路  Source: sindresorhus/got

Describe the bug

  • Node.js version: v12.13.1
  • OS & version: MacOS 10.12.6

Actual behavior

The new config fields for options.https are not merged correctly when extend a got instance.

Expected behavior

If you have an instance of got that has some config of options.https and provide a new one then the resulted instance should has a merged verison.

Code to reproduce

const { describe, it } = require('mocha')
const Got = require('got')
const { deepEqual } = require('assert').strict

describe('Got https options', function () {
    it('should merge http options', function () {
        const got1 = Got.extend({ https: { certificateAuthority: 'TestCertificate' } })
        const got2 = Got.extend(got1, { https: { key: 'TestKey' } })
        deepEqual(got2.defaults.options.https, {
            certificateAuthority: 'TestCertificate',
            key: 'TestKey' 
        })
    })
})

Checklist

  • [X] I have read the documentation.
  • [X] I have tried my code with the latest version of Node.js and Got.

Most helpful comment

We should do deep merge. That鈥檚 the expected behavior.

All 3 comments

You are right, currently the entire https object is merged, not the single options inside it.

@szmarczak I really haven't thought about it, if you think that it should merge every single options I can fix it.

We should do deep merge. That鈥檚 the expected behavior.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexandrino picture alexandrino  路  4Comments

khizarsonu picture khizarsonu  路  3Comments

tkoelpin picture tkoelpin  路  3Comments

dAnjou picture dAnjou  路  3Comments

dominusmars picture dominusmars  路  3Comments