Skip to content

Commit dfee8de

Browse files
authored
refactor: replace deprecated String.prototype.substr() (#691)
`.substr()` is deprecated so we replace it with `.slice()` which works similarly but isn't deprecated. See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr Signed-off-by: Lam Wei Li <[email protected]>
1 parent 1975c5c commit dfee8de

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/contrib/parseuri.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ function pathNames(obj, path) {
4545
const regx = /\/{2,9}/g,
4646
names = path.replace(regx, "/").split("/");
4747

48-
if (path.substr(0, 1) == '/' || path.length === 0) {
48+
if (path.slice(0, 1) == '/' || path.length === 0) {
4949
names.splice(0, 1);
5050
}
51-
if (path.substr(path.length - 1, 1) == '/') {
51+
if (path.slice(-1) == '/') {
5252
names.splice(names.length - 1, 1);
5353
}
5454

0 commit comments

Comments
 (0)