Skip to content

Commit e913761

Browse files
committed
Replaced deprecated subtr method with substring in history package
1 parent bc1c1c8 commit e913761

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.changeset/silver-cats-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
refactor(react-router): Replaced deprecated `substr` with `substring`in history package

packages/react-router/lib/router/history.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ export function createHashHistory(
424424
pathname = "/",
425425
search = "",
426426
hash = "",
427-
} = parsePath(window.location.hash.substr(1));
427+
} = parsePath(window.location.hash.substring(1));
428428

429429
// Hash URL should always have a leading / just like window.location.pathname
430430
// 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) {
510510
}
511511

512512
function createKey() {
513-
return Math.random().toString(36).substr(2, 8);
513+
return Math.random().toString(36).substring(2, 10);
514514
}
515515

516516
/**
@@ -576,14 +576,14 @@ export function parsePath(path: string): Partial<Path> {
576576
if (path) {
577577
let hashIndex = path.indexOf("#");
578578
if (hashIndex >= 0) {
579-
parsedPath.hash = path.substr(hashIndex);
580-
path = path.substr(0, hashIndex);
579+
parsedPath.hash = path.substring(hashIndex);
580+
path = path.substring(0, hashIndex);
581581
}
582582

583583
let searchIndex = path.indexOf("?");
584584
if (searchIndex >= 0) {
585-
parsedPath.search = path.substr(searchIndex);
586-
path = path.substr(0, searchIndex);
585+
parsedPath.search = path.substring(searchIndex);
586+
path = path.substring(0, searchIndex);
587587
}
588588

589589
if (path) {

0 commit comments

Comments
 (0)