Skip to content

Commit

Permalink
chore: ES6 Object spread (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaWong authored May 17, 2020
1 parent 013662a commit eba3b44
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module.exports = function(options) {
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
};

options = Object.assign({}, defaults, options);
options = {
...defaults,
...options,
};

if (Array.isArray(options.exposeHeaders)) {
options.exposeHeaders = options.exposeHeaders.join(',');
Expand Down Expand Up @@ -98,8 +101,11 @@ module.exports = function(options) {
const varyWithOrigin = vary.append(errHeadersSet.vary || errHeadersSet.Vary || '', 'Origin');
delete errHeadersSet.Vary;

err.headers = Object.assign({}, errHeadersSet, headersSet, { vary: varyWithOrigin });

err.headers = {
...errHeadersSet,
...headersSet,
...{ vary: varyWithOrigin },
};
throw err;
}
} else {
Expand Down

0 comments on commit eba3b44

Please sign in to comment.