Skip to content

Commit

Permalink
refactor: replace deprecated String.prototype.substr() (#691)
Browse files Browse the repository at this point in the history
`.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 <peteriman@mail.com>
  • Loading branch information
lamweili authored Jun 14, 2022
1 parent 1975c5c commit dfee8de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/contrib/parseuri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ function pathNames(obj, path) {
const regx = /\/{2,9}/g,
names = path.replace(regx, "/").split("/");

if (path.substr(0, 1) == '/' || path.length === 0) {
if (path.slice(0, 1) == '/' || path.length === 0) {
names.splice(0, 1);
}
if (path.substr(path.length - 1, 1) == '/') {
if (path.slice(-1) == '/') {
names.splice(names.length - 1, 1);
}

Expand Down

0 comments on commit dfee8de

Please sign in to comment.