From 930163aa153c6a19e72f0a1b244ea83f77d48a5f Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 20 Aug 2018 21:16:16 +0800 Subject: [PATCH] fix toInt func --- libs/route-utils/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/route-utils/index.js b/libs/route-utils/index.js index 158273b..c83aa01 100644 --- a/libs/route-utils/index.js +++ b/libs/route-utils/index.js @@ -58,7 +58,7 @@ const toInt = (v, def = 0, min = null, max = null) => { min = isFinite(min) ? (typeof min === 'string' ? parseInt(min) : min) : null max = isFinite(max) ? (typeof max === 'string' ? parseInt(max) : max) : null if (!isFinite(v)) return def - v = parseInt(v) + if (typeof v === 'string') v = parseInt(v) if (min !== null && v < min) v = min if (max !== null && v > max) v = max return v