From 0faa6237f1909a55de2acd68fc74c184e6005f08 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Thu, 24 Mar 2022 16:42:59 +0100 Subject: [PATCH] Replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- js/lib/otp.js | 6 +++--- js/ui/popup/directives/otp.js | 2 +- js/ui/popup/factories/httpsTester.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/js/lib/otp.js b/js/lib/otp.js index 69b1e3cb..18e72a7c 100644 --- a/js/lib/otp.js +++ b/js/lib/otp.js @@ -23,7 +23,7 @@ window.OTP = (function () { } for (i = 0; i + 4 <= bits.length; i += 4) { - var chunk = bits.substr(i, 4); + var chunk = bits.slice(i, i + 4); hex = hex + parseInt(chunk, 2).toString(16); } return hex; @@ -51,8 +51,8 @@ window.OTP = (function () { var hmacObj = new jsSHA(time, 'HEX'); var hmac = hmacObj.getHMAC(key, 'HEX', 'SHA-1', "HEX"); var offset = hex2dec(hmac.substring(hmac.length - 1)); - var otp = (hex2dec(hmac.substr(offset * 2, 8)) & hex2dec('7fffffff')) + ''; - otp = (otp).substr(otp.length - 6, 6); + var otp = (hex2dec(hmac.slice(offset * 2, offset * 2 + 8)) & hex2dec('7fffffff')) + ''; + otp = (otp).slice(-6); return otp; } }; diff --git a/js/ui/popup/directives/otp.js b/js/ui/popup/directives/otp.js index e865f7bf..8705ad8e 100644 --- a/js/ui/popup/directives/otp.js +++ b/js/ui/popup/directives/otp.js @@ -54,7 +54,7 @@ } for (i = 0; i + 4 <= bits.length; i += 4) { - var chunk = bits.substr(i, 4); + var chunk = bits.slice(i, i + 4); hex = hex + parseInt(chunk, 2).toString(16); } return hex; diff --git a/js/ui/popup/factories/httpsTester.js b/js/ui/popup/factories/httpsTester.js index 412a5f67..9e207873 100644 --- a/js/ui/popup/factories/httpsTester.js +++ b/js/ui/popup/factories/httpsTester.js @@ -38,7 +38,7 @@ }; tester.isHTTP = function (url) { - return url.substr(0,5) === 'http:'; + return url.slice(0,5) === 'http:'; }; return tester;