Skip to content

Commit 490f1a1

Browse files
CommanderRootdougwilson
authored andcommitted
lint: remove deprecated String.prototype.substr
closes #4860
1 parent 446046f commit 490f1a1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

lib/router/index.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ proto.param = function param(name, fn) {
108108
var ret;
109109

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

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

181181
// remove added slash
182182
if (slashAdded) {
183-
req.url = req.url.substr(1);
183+
req.url = req.url.slice(1)
184184
slashAdded = false;
185185
}
186186

187187
// restore altered req.url
188188
if (removed.length !== 0) {
189189
req.baseUrl = parentUrl;
190-
req.url = protohost + removed + req.url.substr(protohost.length);
190+
req.url = protohost + removed + req.url.slice(protohost.length)
191191
removed = '';
192192
}
193193

@@ -288,7 +288,7 @@ proto.handle = function handle(req, res, out) {
288288
function trim_prefix(layer, layerError, layerPath, path) {
289289
if (layerPath.length !== 0) {
290290
// Validate path is a prefix match
291-
if (layerPath !== path.substr(0, layerPath.length)) {
291+
if (layerPath !== path.slice(0, layerPath.length)) {
292292
next(layerError)
293293
return
294294
}
@@ -301,7 +301,7 @@ proto.handle = function handle(req, res, out) {
301301
// middleware (.use stuff) needs to have the path stripped
302302
debug('trim prefix (%s) from url %s', layerPath, req.url);
303303
removed = layerPath;
304-
req.url = protohost + req.url.substr(protohost.length + removed.length);
304+
req.url = protohost + req.url.slice(protohost.length + removed.length)
305305

306306
// Ensure leading slash
307307
if (!protohost && req.url[0] !== '/') {
@@ -547,10 +547,10 @@ function getProtohost(url) {
547547
var pathLength = searchIndex !== -1
548548
? searchIndex
549549
: url.length
550-
var fqdnIndex = url.substr(0, pathLength).indexOf('://')
550+
var fqdnIndex = url.slice(0, pathLength).indexOf('://')
551551

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

lib/view.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function View(name, options) {
7474

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

8080
// default engine export

0 commit comments

Comments
 (0)