From 2257875db752c133c4b38424599e115cf959c4ff Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 19 Nov 2018 11:43:08 +0800 Subject: [PATCH] forbid "undefined" cache value --- middleware/lru-cache.js | 2 +- middleware/redis-cache.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/lru-cache.js b/middleware/lru-cache.js index 073408f068..5c8790ffb6 100644 --- a/middleware/lru-cache.js +++ b/middleware/lru-cache.js @@ -26,7 +26,7 @@ module.exports = function(options = {}) { } }, set: (key, value, maxAge) => { - if (!value) { + if (!value || value === 'undefined') { value = ''; } if (typeof value === 'object') { diff --git a/middleware/redis-cache.js b/middleware/redis-cache.js index 309ae776c2..0cc8d4f72d 100644 --- a/middleware/redis-cache.js +++ b/middleware/redis-cache.js @@ -47,7 +47,7 @@ module.exports = function(options = {}) { } }, set: async (key, value, maxAge) => { - if (!value) { + if (!value || value === 'undefined') { value = ''; } if (typeof value === 'object') {