Skip to content

Commit

Permalink
refactor(@dpc-sdp/ripple-nuxt-tide): update sitemap proxying to match…
Browse files Browse the repository at this point in the history
… drupal updates (#1278)

Co-authored-by: David Featherston <david.featherstone@dpc.vic.gov.au>
  • Loading branch information
lambry and David Featherston committed Mar 9, 2023
1 parent 4e5465e commit 1197816
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions packages/ripple-nuxt-tide/modules/site/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function () {
})

const getQuery = (req) => {
return req.query ? '&' + new URLSearchParams(req.query).toString() : ''
return req?.query && Object.keys(req.query).length ? '?' + new URLSearchParams(req.query).toString() : ''
}

// This won't override nuxt tide module's proxy option, as they have been added into array already.
Expand All @@ -21,19 +21,7 @@ module.exports = function () {
'/sitemap.xml': {
target: baseUrl,
pathRewrite: (path, req) => {
return baseUrl + 'sitemap.xml?site=' + options.site + getQuery(req)
}
},
'/**/sitemap.xml': {
target: baseUrl,
pathRewrite: (path, req) => {
return baseUrl + path + '?site=' + options.site + getQuery(req)
}
},
'/sitemaps/**/sitemap.xml': {
target: baseUrl,
pathRewrite: (path, req) => {
return baseUrl + path + '?site=' + options.site + getQuery(req)
return baseUrl + `site-${options.site}/sitemap.xml` + getQuery(req)
}
}
}
Expand Down

0 comments on commit 1197816

Please sign in to comment.