From a934cc9e75d5222b05c0832d6a43c2c45852a1a2 Mon Sep 17 00:00:00 2001 From: Bilal Kazmi Date: Mon, 21 Oct 2024 22:38:14 +0500 Subject: [PATCH] refactor(react-router): replace `substr` with `substring` (#12080) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replaced deprecated subtr method with substring in history package * Update .changeset/silver-cats-shave.md --------- Co-authored-by: Michaƫl De Boey --- .changeset/silver-cats-shave.md | 5 +++++ packages/react-router/lib/router/history.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .changeset/silver-cats-shave.md diff --git a/.changeset/silver-cats-shave.md b/.changeset/silver-cats-shave.md new file mode 100644 index 0000000000..698836f2c7 --- /dev/null +++ b/.changeset/silver-cats-shave.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +Replace `substr` with `substring` diff --git a/packages/react-router/lib/router/history.ts b/packages/react-router/lib/router/history.ts index 1118193972..e7e07ac28b 100644 --- a/packages/react-router/lib/router/history.ts +++ b/packages/react-router/lib/router/history.ts @@ -424,7 +424,7 @@ export function createHashHistory( pathname = "/", search = "", hash = "", - } = parsePath(window.location.hash.substr(1)); + } = parsePath(window.location.hash.substring(1)); // Hash URL should always have a leading / just like window.location.pathname // does, so if an app ends up at a route like /#something then we add a @@ -510,7 +510,7 @@ export function warning(cond: any, message: string) { } function createKey() { - return Math.random().toString(36).substr(2, 8); + return Math.random().toString(36).substring(2, 10); } /** @@ -576,14 +576,14 @@ export function parsePath(path: string): Partial { if (path) { let hashIndex = path.indexOf("#"); if (hashIndex >= 0) { - parsedPath.hash = path.substr(hashIndex); - path = path.substr(0, hashIndex); + parsedPath.hash = path.substring(hashIndex); + path = path.substring(0, hashIndex); } let searchIndex = path.indexOf("?"); if (searchIndex >= 0) { - parsedPath.search = path.substr(searchIndex); - path = path.substr(0, searchIndex); + parsedPath.search = path.substring(searchIndex); + path = path.substring(0, searchIndex); } if (path) {