1
Fork 0
mirror of https://github.com/diced/zipline.git synced 2025-04-11 23:31:17 -05:00

fix: vanities can be overwritten

This commit is contained in:
diced 2022-07-28 14:03:29 -07:00
parent f3a23a528b
commit 7c887e8ec1
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -20,6 +20,17 @@ async function handler(req: NextApiReq, res: NextApiRes) {
const rand = randomChars(zconfig.urls.length);
let invis;
if (req.body.vanity) {
const existing = await prisma.url.findFirst({
where: {
vanity: req.body.vanity,
},
});
if (existing) return res.error('vanity already exists');
}
const url = await prisma.url.create({
data: {
id: rand,