You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/site/src/routes/repl/local/[...file].js

18 lines
412 B

import { createReadStream } from 'fs';
export function get(req, res) {
const path = req.params.file.join('/');
if (process.env.NODE_ENV !== 'development' || ('/' + path).includes('/.')) {
res.writeHead(403);
res.end();
return;
}
createReadStream('../' + path)
.on('error', () => {
res.writeHead(403);
res.end();
})
.pipe(res);
res.writeHead(200, { 'Content-Type': 'text/javascript' });
}