Skip to content

Commit

Permalink
lint: remove deprecated String.prototype.substr
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderRoot authored and himanshiLt committed Jun 20, 2022
1 parent e6596e4 commit dcc256a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ proto.param = function param(name, fn) {
var ret;

if (name[0] === ':') {
deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.substr(1)) + ', fn) instead');
name = name.substr(1);
deprecate('router.param(' + JSON.stringify(name) + ', fn): Use router.param(' + JSON.stringify(name.slice(1)) + ', fn) instead')
name = name.slice(1)
}

for (var i = 0; i < len; ++i) {
Expand Down Expand Up @@ -180,14 +180,14 @@ proto.handle = function handle(req, res, out) {

// remove added slash
if (slashAdded) {
req.url = req.url.substr(1);
req.url = req.url.slice(1)
slashAdded = false;
}

// restore altered req.url
if (removed.length !== 0) {
req.baseUrl = parentUrl;
req.url = protohost + removed + req.url.substr(protohost.length);
req.url = protohost + removed + req.url.slice(protohost.length)
removed = '';
}

Expand Down Expand Up @@ -288,7 +288,7 @@ proto.handle = function handle(req, res, out) {
function trim_prefix(layer, layerError, layerPath, path) {
if (layerPath.length !== 0) {
// Validate path is a prefix match
if (layerPath !== path.substr(0, layerPath.length)) {
if (layerPath !== path.slice(0, layerPath.length)) {
next(layerError)
return
}
Expand All @@ -301,7 +301,7 @@ proto.handle = function handle(req, res, out) {
// middleware (.use stuff) needs to have the path stripped
debug('trim prefix (%s) from url %s', layerPath, req.url);
removed = layerPath;
req.url = protohost + req.url.substr(protohost.length + removed.length);
req.url = protohost + req.url.slice(protohost.length + removed.length)

// Ensure leading slash
if (!protohost && req.url[0] !== '/') {
Expand Down Expand Up @@ -547,10 +547,10 @@ function getProtohost(url) {
var pathLength = searchIndex !== -1
? searchIndex
: url.length
var fqdnIndex = url.substr(0, pathLength).indexOf('://')
var fqdnIndex = url.slice(0, pathLength).indexOf('://')

return fqdnIndex !== -1
? url.substr(0, url.indexOf('/', 3 + fqdnIndex))
? url.substring(0, url.indexOf('/', 3 + fqdnIndex))
: undefined
}

Expand Down
2 changes: 1 addition & 1 deletion lib/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function View(name, options) {

if (!opts.engines[this.ext]) {
// load engine
var mod = this.ext.substr(1)
var mod = this.ext.slice(1)
debug('require "%s"', mod)

// default engine export
Expand Down

0 comments on commit dcc256a

Please sign in to comment.