From e913761208d5c51d6b72b728ed5febabaad4a28f Mon Sep 17 00:00:00 2001 From: Bilal Kazmi Date: Sun, 20 Oct 2024 16:37:15 +0500 Subject: [PATCH 1/2] Replaced deprecated subtr method with substring in history package --- .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..7e9f2f4b62 --- /dev/null +++ b/.changeset/silver-cats-shave.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +refactor(react-router): Replaced deprecated `substr` with `substring`in history package 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) { From cf98cdee54228fd9899e59541c6f573eaa6ab8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 21 Oct 2024 19:25:24 +0200 Subject: [PATCH 2/2] Update .changeset/silver-cats-shave.md --- .changeset/silver-cats-shave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/silver-cats-shave.md b/.changeset/silver-cats-shave.md index 7e9f2f4b62..698836f2c7 100644 --- a/.changeset/silver-cats-shave.md +++ b/.changeset/silver-cats-shave.md @@ -2,4 +2,4 @@ "react-router": patch --- -refactor(react-router): Replaced deprecated `substr` with `substring`in history package +Replace `substr` with `substring`