Merge pull request #1265 from thegitone23/local-develop

Added safegaurd against invalid project id and undefined file path
This commit is contained in:
Cassie Tarakajian 2020-03-30 17:11:32 -04:00 committed by GitHub
commit 7f8ab3cded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -111,7 +111,7 @@ export function deleteFile(req, res) {
export function getFileContent(req, res) { export function getFileContent(req, res) {
Project.findById(req.params.project_id, (err, project) => { Project.findById(req.params.project_id, (err, project) => {
if (err) { if (err || project === null) {
res.status(404).send({ success: false, message: 'Project with that id does not exist.' }); res.status(404).send({ success: false, message: 'Project with that id does not exist.' });
return; return;
} }

View file

@ -1,4 +1,8 @@
export function resolvePathToFile(filePath, files) { export function resolvePathToFile(filePath, files) {
if (filePath === undefined) {
return false;
}
const filePathArray = filePath.split('/'); const filePathArray = filePath.split('/');
let resolvedFile; let resolvedFile;
let currentFile = files.find(file => file.name === 'root'); let currentFile = files.find(file => file.name === 'root');