serve-handler
Advanced tools
Comparing version 2.1.0 to 2.1.1
{ | ||
"name": "serve-handler", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "The routing foundation of `serve` and static deployments on Now", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -253,9 +253,13 @@ // Native | ||
const renderDirectory = async (current, relativePath, absolutePath, {readdir, stat}) => { | ||
let files = await readdir(absolutePath); | ||
const renderDirectory = async (current, relativePath, absolutePath, handlers, config) => { | ||
if (!applicable(relativePath, config.directoryListing, false)) { | ||
return null; | ||
} | ||
let files = await handlers.readdir(absolutePath); | ||
for (const file of files) { | ||
const filePath = path.resolve(absolutePath, file); | ||
const details = path.parse(filePath); | ||
const stats = await stat(filePath); | ||
const stats = await handlers.stat(filePath); | ||
@@ -413,15 +417,6 @@ details.relative = path.join(relativePath, details.base); | ||
const canList = applicable(decodedPath, config.directoryListing, false); | ||
if (!canList) { | ||
response.statusCode = 404; | ||
response.end('Not Found'); | ||
return; | ||
} | ||
let directory = null; | ||
try { | ||
directory = await renderDirectory(current, relativePath, absolutePath, handlers); | ||
directory = await renderDirectory(current, relativePath, absolutePath, handlers, config); | ||
} catch (err) { | ||
@@ -434,4 +429,4 @@ response.statusCode = 500; | ||
response.statusCode = 200; | ||
response.end(directory); | ||
response.statusCode = directory ? 200 : 404; | ||
response.end(directory || 'Not Found'); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18837
333