Skip to content

Commit

Permalink
refactor(react-router): replace substr with substring (#12080)
Browse files Browse the repository at this point in the history
* Replaced deprecated subtr method with substring in history package

* Update .changeset/silver-cats-shave.md

---------

Co-authored-by: Michaël De Boey <[email protected]>
  • Loading branch information
bilalk711 and MichaelDeBoey authored Oct 21, 2024
1 parent 02b363c commit a934cc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/silver-cats-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router": patch
---

Replace `substr` with `substring`
12 changes: 6 additions & 6 deletions packages/react-router/lib/router/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -576,14 +576,14 @@ export function parsePath(path: string): Partial<Path> {
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) {
Expand Down

0 comments on commit a934cc9

Please sign in to comment.