Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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