diff options
author | CommanderRoot <CommanderRoot@users.noreply.github.com> | 2022-04-04 21:08:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-04 21:08:43 +0300 |
commit | e3da5df4152fbe547f7871547165328e1bf06262 (patch) | |
tree | 273fd46ffb39ca4499af4a5b6a8807ba2b32b382 /lib/search | |
parent | 44108f7be5e1e928d8aa3eda3c5c177bcd216c99 (diff) |
fix: replace deprecated String.prototype.substr() (#4667)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
Diffstat (limited to 'lib/search')
-rw-r--r-- | lib/search/format-package-stream.js | 6 | ||||
-rw-r--r-- | lib/search/package-filter.js | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/search/format-package-stream.js b/lib/search/format-package-stream.js index 7ff44e9e2..acead79e1 100644 --- a/lib/search/format-package-stream.js +++ b/lib/search/format-package-stream.js @@ -111,7 +111,7 @@ function addColorMarker (str, arg, i) { if (arg.charAt(0) === '/') { return str.replace( - new RegExp(arg.substr(1, arg.length - 2), 'gi'), + new RegExp(arg.slice(1, -1), 'gi'), bit => markStart + bit + markEnd ) } @@ -121,9 +121,9 @@ function addColorMarker (str, arg, i) { var p = 0 return pieces.map(function (piece) { - piece = str.substr(p, piece.length) + piece = str.slice(p, p + piece.length) var mark = markStart + - str.substr(p + piece.length, arg.length) + + str.slice(p + piece.length, p + piece.length + arg.length) + markEnd p += piece.length + arg.length return piece + mark diff --git a/lib/search/package-filter.js b/lib/search/package-filter.js index 45a67835b..bb0ae679b 100644 --- a/lib/search/package-filter.js +++ b/lib/search/package-filter.js @@ -36,7 +36,7 @@ function filterWords (data, include, exclude, opts) { function match (words, pattern) { if (pattern.charAt(0) === '/') { pattern = pattern.replace(/\/$/, '') - pattern = new RegExp(pattern.substr(1, pattern.length - 1)) + pattern = new RegExp(pattern.slice(1)) return words.match(pattern) } return words.indexOf(pattern) !== -1 |