From c82ea5c1be7035a017763d44a4539bd4a253d9e3 Mon Sep 17 00:00:00 2001 From: Josh Kelley Date: Tue, 2 Nov 2021 15:26:51 -0400 Subject: [PATCH] More flexible / forgiving specification of byte sizes --- app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 9277400..85c1232 100644 --- a/app.js +++ b/app.js @@ -51,11 +51,11 @@ function get_limit_size() { return (1024 * 1024 * 10); if (typeof(conf.max_size) !== 'string') conf.max_size = conf.max_size + ""; - if (conf.max_size.slice(-1) === 'G') + if (/GB?$/i.test(conf.max_size)) return (parseInt(conf.max_size) * 1024 * 1024 * 1024); - if (conf.max_size.slice(-1) === 'M') + if (/MB?$/i.test(conf.max_size)) return (parseInt(conf.max_size) * 1024 * 1024); - if (conf.max_size.slice(-1) === 'K') + if (/KB?$/i.test(conf.max_size)) return (parseInt(conf.max_size) * 1024); return parseInt(conf.max_size); }