From 2cb7888682f4a249d1e4563fc8dcb939046e85a9 Mon Sep 17 00:00:00 2001 From: niftylettuce Date: Fri, 15 May 2020 12:13:17 -0500 Subject: [PATCH] Revert "Using `RegExp` replace loop in `isHidden` (#109)" (#138) This reverts commit 83300283a6b890d94c8c96b19c9d1425c945e10e. --- index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 411cd8c..18b4a36 100644 --- a/index.js +++ b/index.js @@ -147,10 +147,11 @@ async function send (ctx, path, opts = {}) { */ function isHidden (root, path) { - const hiddenFileReg = new RegExp(`${sep}\\.`) - path = path.substr(root.length) - - return hiddenFileReg.test(path) + path = path.substr(root.length).split(sep) + for (let i = 0; i < path.length; i++) { + if (path[i][0] === '.') return true + } + return false } /**