Skip to content
Myr

Merge pull request #2065 from WebReflection/patch-1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

trim_prefix causing --use-strict flag to fail

authored by Roman Shtylman · committed by Roman Shtylman · parents bdb3bb9, 4ac7474 · Browse files · 1 file+27 added−25 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+27 added−25 removed

  • other:+27 added−25 removed

1 file+27 added−25 removed

modified:lib/router/index.js+27 added-25 removed
196 unmodified lines
197198 trim_prefix();199 });200201 function trim_prefix() {202 var c = path[layer.path.length];203 if (c && '/' != c && '.' != c) return next(err);201 } catch (err) {202 next(err);203 }204205 // Trim off the part of the url that matches the route206 // middleware (.use stuff) needs to have the path stripped207 debug('trim prefix (%s) from url %s', removed, req.url);208 removed = layer.path;209 req.url = protohost + req.url.substr(protohost.length + removed.length);205 function trim_prefix() {206 var c = path[layer.path.length];207 if (c && '/' != c && '.' != c) return next(err);208211 // Ensure leading slash212 if (!fqdn && '/' != req.url[0]) {213 req.url = '/' + req.url;214 slashAdded = true;215 }209 // Trim off the part of the url that matches the route210 // middleware (.use stuff) needs to have the path stripped211 debug('trim prefix (%s) from url %s', removed, req.url);212 removed = layer.path;213 req.url = protohost + req.url.substr(protohost.length + removed.length);214217 debug('%s %s : %s', layer.handle.name || 'anonymous', layer.path, req.originalUrl);218 var arity = layer.handle.length;219 if (err) {220 if (arity === 4) {221 layer.handle(err, req, res, next);222 } else {223 next(err);224 }225 } else if (arity < 4) {226 layer.handle(req, res, next);215 // Ensure leading slash216 if (!fqdn && '/' != req.url[0]) {217 req.url = '/' + req.url;218 slashAdded = true;219 }220221 debug('%s %s : %s', layer.handle.name || 'anonymous', layer.path, req.originalUrl);222 var arity = layer.handle.length;223 if (err) {224 if (arity === 4) {225 layer.handle(err, req, res, next);226 } else {227 next(err);228 }229 } else if (arity < 4) {230 layer.handle(req, res, next);231 } else {232 next(err);233 }231 } catch (err) {232 next(err);234 }235236 })();237};238239/**
146 unmodified lines