diff --git a/index.js b/index.js index 559b7e5..38ca23a 100644 --- a/index.js +++ b/index.js @@ -498,7 +498,7 @@ function findIndexFile (pathname, root, indexFiles = ['index.html']) { try { const stats = statSync(p) return !stats.isDirectory() - } catch (e) { + } catch { return false } }) @@ -542,7 +542,7 @@ function getRedirectUrl (url) { const parsed = new URL(url, 'http://localhost.com/') const parsedPathname = parsed.pathname return parsedPathname + (parsedPathname[parsedPathname.length - 1] !== '/' ? '/' : '') + (parsed.search || '') - } catch (error) { + } catch { // the try-catch here is actually unreachable, but we keep it for safety and prevent DoS attack /* istanbul ignore next */ const err = new Error(`Invalid redirect URL: ${url}`) diff --git a/lib/dirList.js b/lib/dirList.js index 12d75b2..d179156 100644 --- a/lib/dirList.js +++ b/lib/dirList.js @@ -27,7 +27,7 @@ const dirList = { let stats try { stats = await fs.stat(path.join(dir, filename)) - } catch (error) { + } catch { return } const entry = { name: filename, stats } @@ -58,7 +58,7 @@ const dirList = { let stats try { stats = await fs.stat(filePath) - } catch (error) { + } catch { return } @@ -112,7 +112,7 @@ const dirList = { let entries try { entries = await dirList.list(dir, options, dotfiles) - } catch (error) { + } catch { return reply.callNotFound() } const format = reply.request.query.format || options.format