Skip to content

Commit

Permalink
fix: force route.url as string
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoPennec committed Apr 5, 2020
1 parent a955318 commit dc521ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/builder.js
Expand Up @@ -59,7 +59,7 @@ function createSitemap(options, routes, base = null, req = null) {
// Normalize to absolute path
return {
...sitemapOptions,
url: join('.', sitemapOptions.url),
url: join('.', String(sitemapOptions.url)),
}
})

Expand Down
9 changes: 6 additions & 3 deletions lib/cache.js
Expand Up @@ -48,7 +48,7 @@ function promisifyRoute(fn) {
// If routes is a function expecting a callback
if (fn.length === 1) {
return new Promise((resolve, reject) => {
fn(function(err, routeParams) {
fn(function (err, routeParams) {
if (err) {
reject(err)
}
Expand Down Expand Up @@ -80,13 +80,16 @@ function joinRoutes(staticRoutes, dynamicRoutes) {
}

/**
* Make sure a route is an object with "url" property
* Make sure a route is an object with an "url" string property
*
* @param {Object | string} route Route Object or Payload Object or String value
* @returns {Object} A valid route object
*/
function ensureIsValidRoute(route) {
return typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
route = typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
// force as string
route.url = String(route.url)
return route
}

module.exports = { createRoutesCache }

0 comments on commit dc521ab

Please sign in to comment.