Skip to content

Commit dc521ab

Browse files
committedApr 5, 2020
fix: force route.url as string
1 parent a955318 commit dc521ab

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed
 

‎lib/builder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function createSitemap(options, routes, base = null, req = null) {
5959
// Normalize to absolute path
6060
return {
6161
...sitemapOptions,
62-
url: join('.', sitemapOptions.url),
62+
url: join('.', String(sitemapOptions.url)),
6363
}
6464
})
6565

‎lib/cache.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function promisifyRoute(fn) {
4848
// If routes is a function expecting a callback
4949
if (fn.length === 1) {
5050
return new Promise((resolve, reject) => {
51-
fn(function(err, routeParams) {
51+
fn(function (err, routeParams) {
5252
if (err) {
5353
reject(err)
5454
}
@@ -80,13 +80,16 @@ function joinRoutes(staticRoutes, dynamicRoutes) {
8080
}
8181

8282
/**
83-
* Make sure a route is an object with "url" property
83+
* Make sure a route is an object with an "url" string property
8484
*
8585
* @param {Object | string} route Route Object or Payload Object or String value
8686
* @returns {Object} A valid route object
8787
*/
8888
function ensureIsValidRoute(route) {
89-
return typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
89+
route = typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route }
90+
// force as string
91+
route.url = String(route.url)
92+
return route
9093
}
9194

9295
module.exports = { createRoutesCache }

0 commit comments

Comments
 (0)
Please sign in to comment.