Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if ( [ 'HEAD', 'GET' ].indexOf( this.method ) === -1 ) {
return;
}
let path = this.captures[0];
path = path[ 0 ] === '/' ? path.slice( 1 ) : path;
try {
path = decodeURIComponent( path )
} catch ( err ) {
application.log.error( 'Could not decode path' );
application.log.debug( err );
this.throw( 'failed to decode', 400 );
}
path = resolvePath( root, path );
if ( basename( path )[ 0 ] === '.' ) {
return;
}
let stats;
try {
stats = await stat( path );
if ( stats.isDirectory() ) {
return;
}
} catch ( err ) {
if ( notfound.indexOf( err.code ) > -1 ) {
return;
}