重构模拟器工作台与日志浮层
This commit is contained in:
@@ -57,7 +57,12 @@ function respondJson(response, statusCode, payload) {
|
||||
}
|
||||
|
||||
function serveStatic(requestPath, response) {
|
||||
const safePath = requestPath === '/' ? '/index.html' : requestPath
|
||||
let safePath = requestPath === '/' ? '/index.html' : requestPath
|
||||
if (safePath.endsWith('/')) {
|
||||
safePath = `${safePath}index.html`
|
||||
} else if (!path.extname(safePath)) {
|
||||
safePath = `${safePath}/index.html`
|
||||
}
|
||||
const resolvedPath = path.normalize(path.join(PUBLIC_DIR, safePath))
|
||||
if (!resolvedPath.startsWith(PUBLIC_DIR)) {
|
||||
response.writeHead(403)
|
||||
|
||||
Reference in New Issue
Block a user