@jsenv/server
Advanced tools
Comparing version 12.5.3 to 12.5.4
{ | ||
"name": "@jsenv/server", | ||
"version": "12.5.3", | ||
"version": "12.5.4", | ||
"description": "Write your Node.js server using pure functions", | ||
@@ -19,3 +19,4 @@ "license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
@@ -71,2 +72,2 @@ "type": "module", | ||
} | ||
} | ||
} |
@@ -92,7 +92,13 @@ /* | ||
if (sourceStat.isDirectory()) { | ||
return serveDirectory(urlString, { | ||
headers, | ||
canReadDirectory, | ||
rootDirectoryUrl, | ||
}) | ||
if (canReadDirectory) { | ||
return serveDirectory(urlString, { | ||
headers, | ||
canReadDirectory, | ||
rootDirectoryUrl, | ||
}) | ||
} | ||
return { | ||
status: 403, | ||
statusText: "not allowed to read directory", | ||
} | ||
} | ||
@@ -99,0 +105,0 @@ // not a file, give up |
@@ -8,14 +8,4 @@ import { readdirSync } from "node:fs" | ||
url, | ||
{ | ||
headers = {}, | ||
canReadDirectory = false, | ||
rootDirectoryUrl = `${pathToFileURL(process.cwd())}/`, | ||
} = {}, | ||
{ headers = {}, rootDirectoryUrl = `${pathToFileURL(process.cwd())}/` } = {}, | ||
) => { | ||
if (canReadDirectory === false) { | ||
return { | ||
status: 403, | ||
statusText: "not allowed to read directory", | ||
} | ||
} | ||
url = String(url) | ||
@@ -22,0 +12,0 @@ url = url[url.length - 1] === "/" ? url : `${url}/` |
134615
4201