Skip to content
Permalink
Browse files

refactor: use object spread operator

  • Loading branch information...
NicoPennec committed May 10, 2019
1 parent 0cf1ab1 commit a45de6fc28a27d2ef40c8eca7de8eb6af1caca99
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/module.js
@@ -24,7 +24,12 @@ module.exports = function module (moduleOptions) {
defaults: {}
}

const options = Object.assign({}, defaults, this.options.sitemap, moduleOptions)
const options = {
...defaults,
...this.options.sitemap,
...moduleOptions
}

options.pathGzip = options.gzip ? `${options.path}.gz` : options.path

// sitemap-routes.json is written to dist dir on "build" mode
@@ -155,11 +160,11 @@ function createSitemap (options, routes, req) {
sitemapConfig.hostname = options.hostname ||
(req && `${isHTTPS(req) ? 'https' : 'http'}://${req.headers.host}`) || `http://${hostname()}`

routes = routes.map(route => Object.assign({}, options.defaults, route))
routes = routes.map(route => ({ ...options.defaults, ...route }))

// Enable filter function for each declared route
if (typeof options.filter === 'function') {
routes = options.filter({ routes, options: Object.assign({}, options, sitemapConfig) })
routes = options.filter({ routes, options: { ...options, ...sitemapConfig } })
}

// Set urls and ensure they are unique

0 comments on commit a45de6f

Please sign in to comment.
You can’t perform that action at this time.