From 70278c2e697e07f103c619d4f69287a694aff2c1 Mon Sep 17 00:00:00 2001 From: Avet <29avet1@gmail.com> Date: Mon, 21 Feb 2022 17:18:20 +0400 Subject: [PATCH 1/5] Update cache.js --- lib/cache.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index ef613f94..41925b3a 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -85,11 +85,25 @@ function joinRoutes(staticRoutes, dynamicRoutes) { * @param {Object | string} route Route Object or Payload Object or String value * @returns {Object} A valid route object */ + function ensureIsValidRoute(route) { - route = typeof route === 'object' ? (route.route ? { url: route.route } : route) : { url: route } - // force as string - route.url = String(route.url) - return route + if (typeof route === 'string') { + return { url: route } + } + if (typeof route === 'object') { + const routeToReturn = {} + if (route.route) { + routeToReturn.url = route.route + } + if(route.name) { + routeToReturn.name = route.name + } + routeToReturn.url = String(routeToReturn.url) + + return routeToReturn; + } + + return route; } module.exports = { createRoutesCache } From 5205fd38e2304b321d6dfaa6b4e1f6fe9edcac92 Mon Sep 17 00:00:00 2001 From: Avet <29avet1@gmail.com> Date: Mon, 21 Feb 2022 17:49:15 +0400 Subject: [PATCH 2/5] Update cache.js --- lib/cache.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index 41925b3a..228bc88b 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -93,12 +93,11 @@ function ensureIsValidRoute(route) { if (typeof route === 'object') { const routeToReturn = {} if (route.route) { - routeToReturn.url = route.route + routeToReturn.url = String(route.route) } if(route.name) { routeToReturn.name = route.name } - routeToReturn.url = String(routeToReturn.url) return routeToReturn; } From 120379b897d7e1745e020ac90104f2cbd98ac28c Mon Sep 17 00:00:00 2001 From: Avet <29avet1@gmail.com> Date: Mon, 21 Feb 2022 19:15:32 +0400 Subject: [PATCH 3/5] Update cache.js --- lib/cache.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/cache.js b/lib/cache.js index 228bc88b..a4c1fae6 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -85,7 +85,6 @@ function joinRoutes(staticRoutes, dynamicRoutes) { * @param {Object | string} route Route Object or Payload Object or String value * @returns {Object} A valid route object */ - function ensureIsValidRoute(route) { if (typeof route === 'string') { return { url: route } From 4c7ed09b20da0490e5fcf8380c5315e3d88a75a3 Mon Sep 17 00:00:00 2001 From: Avet <29avet1@gmail.com> Date: Mon, 21 Feb 2022 19:30:36 +0400 Subject: [PATCH 4/5] Update cache.js --- lib/cache.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/cache.js b/lib/cache.js index a4c1fae6..984bddf7 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -86,22 +86,20 @@ function joinRoutes(staticRoutes, dynamicRoutes) { * @returns {Object} A valid route object */ function ensureIsValidRoute(route) { - if (typeof route === 'string') { - return { url: route } - } + let routeToReturn = null; if (typeof route === 'object') { - const routeToReturn = {} - if (route.route) { - routeToReturn.url = String(route.route) - } + routeToReturn = route.route ? { url: route.route } : route + if(route.name) { routeToReturn.name = route.name } - - return routeToReturn; + } else { + routeToReturn = { url: route }; } - return route; + routeToReturn.url = String(routeToReturn.url); + + return routeToReturn; } module.exports = { createRoutesCache } From a851c928068efab01891c876e660aaa8647c7b53 Mon Sep 17 00:00:00 2001 From: Avet Antonyan <29avet1@gmail.com> Date: Thu, 24 Aug 2023 20:01:05 +0400 Subject: [PATCH 5/5] Update cache.js -add lastmod option --- lib/cache.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cache.js b/lib/cache.js index 984bddf7..8f418bec 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -93,6 +93,10 @@ function ensureIsValidRoute(route) { if(route.name) { routeToReturn.name = route.name } + + if(route.lastmod) { + routeToReturn.lastmod = route.lastmod + } } else { routeToReturn = { url: route }; }