correct path matching

This commit is contained in:
Kamil Tunkiewicz 2020-10-16 19:44:30 +02:00
parent df6b922330
commit c1d5ab3468

View File

@ -204,7 +204,7 @@ async function serve(port: number, pathToSpec: string, options: Options = {}) {
} else { } else {
const filePath = normalize(join(dirname(pathToSpec), request.url || '')); const filePath = normalize(join(dirname(pathToSpec), request.url || ''));
const relativePath = relative(dirname(pathToSpec), filePath); const relativePath = relative(dirname(pathToSpec), filePath);
if (options.static && options.static !== '' && relativePath.startsWith(options.static)) { if (options.static && options.static !== '' && relativePath.startsWith(options.static + '/')) {
const file = createReadStream(filePath); const file = createReadStream(filePath);
file.on('open', function () { file.on('open', function () {
response.setHeader('Content-Type', lookup(filePath) || 'text/plain'); response.setHeader('Content-Type', lookup(filePath) || 'text/plain');