From a7ccab1dd3b06b0ff7cb88ad9e1702831c0c7e84 Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Fri, 18 Mar 2022 12:25:54 +0100 Subject: [PATCH] chore: replace deprecated String.prototype.substr() (#4343) --- client-src/utils/createSocketURL.js | 2 +- client-src/utils/parseURL.js | 2 +- test/e2e/range-header.test.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client-src/utils/createSocketURL.js b/client-src/utils/createSocketURL.js index 5d8a28ddbd..b79d994829 100644 --- a/client-src/utils/createSocketURL.js +++ b/client-src/utils/createSocketURL.js @@ -5,7 +5,7 @@ function format(objURL) { let protocol = objURL.protocol || ""; - if (protocol && protocol.substr(-1) !== ":") { + if (protocol && !protocol.endsWith(":")) { protocol += ":"; } diff --git a/client-src/utils/parseURL.js b/client-src/utils/parseURL.js index 3a4f2f3fda..9e9b5e4422 100644 --- a/client-src/utils/parseURL.js +++ b/client-src/utils/parseURL.js @@ -9,7 +9,7 @@ function parseURL(resourceQuery) { let options = {}; if (typeof resourceQuery === "string" && resourceQuery !== "") { - const searchParams = resourceQuery.substr(1).split("&"); + const searchParams = resourceQuery.slice(1).split("&"); for (let i = 0; i < searchParams.length; i++) { const pair = searchParams[i].split("="); diff --git a/test/e2e/range-header.test.js b/test/e2e/range-header.test.js index 39b8703ed2..312fb6042b 100644 --- a/test/e2e/range-header.test.js +++ b/test/e2e/range-header.test.js @@ -42,7 +42,7 @@ describe("'Range' header", () => { ); expect(responseRange.headers["content-length"]).toBe("500"); expect(responseRange.headers["content-range"]).toMatch(/^bytes 0-499\//); - expect(responseRange.text).toBe(responseContent.substr(0, 500)); + expect(responseRange.text).toBe(responseContent.slice(0, 500)); expect(responseRange.text.length).toBe(500); });