Skip to content

Commit

Permalink
fix: only merge simple objects (part II)
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Oct 31, 2018
1 parent 0105ad9 commit d3e4f1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions lib/endpoint-with-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ function endpointWithDefaults (defaults, route, options) {
}

// Only return body/request keys if present
const funk = Object.assign(
return Object.assign(
{ method, url, headers },
typeof body !== 'undefined' ? { body } : null,
options.request ? { request: options.request } : null
)

return funk
}
3 changes: 2 additions & 1 deletion with-defaults.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module.exports = withDefaults

const merge = require('deepmerge')
const isPlainObject = require('is-plain-object')

const endpointWithDefaults = require('./lib/endpoint-with-defaults')

function withDefaults (oldDefaults, newDefaults) {
const DEFAULTS = merge.all([oldDefaults, newDefaults].filter(Boolean))
const DEFAULTS = merge.all([oldDefaults, newDefaults].filter(Boolean), { isMergeableObject: isPlainObject })
const endpoint = endpointWithDefaults.bind(null, DEFAULTS)
endpoint.DEFAULTS = DEFAULTS
endpoint.defaults = withDefaults.bind(null, DEFAULTS)
Expand Down

0 comments on commit d3e4f1d

Please sign in to comment.