This commit is contained in:
Jori Lallo
2016-08-18 14:42:53 -07:00
parent 3089ac7bc8
commit e3e5ead9e0
5 changed files with 35 additions and 11 deletions

View File

@ -4,7 +4,7 @@ import {
sequelize,
} from '../sequelize';
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{15})$/;
const URL_REGEX = /^[a-zA-Z0-9-]*-([a-zA-Z0-9]{10,15})$/;
import auth from './authentication';
// import pagination from './middlewares/pagination';
@ -22,11 +22,16 @@ const getDocumentForId = async (id) => {
},
});
} else {
document = await Document.findOne({
where: {
id,
},
});
try {
document = await Document.findOne({
where: {
id,
},
});
} catch (e) {
// Invalid UUID
throw httpErrors.NotFound();
}
}
return document;
};