From d83c446172e8a6404e3429e4b5f21f8b94f6073a Mon Sep 17 00:00:00 2001 From: Shubham Kumar Date: Sun, 29 Sep 2024 17:51:13 +0530 Subject: [PATCH] Refactor: use slice() instead of deprecated substr() to avoid future issues --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index dd6d479..4e175bd 100644 --- a/index.js +++ b/index.js @@ -81,7 +81,7 @@ function cookieParser (secret, options) { */ function JSONCookie (str) { - if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') { + if (typeof str !== 'string' || str.slice(0, 2) !== 'j:') { return undefined } @@ -131,7 +131,7 @@ function signedCookie (str, secret) { return undefined } - if (str.substr(0, 2) !== 's:') { + if (str.slice(0, 2) !== 's:') { return str }