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:
parent
f3a23a528b
commit
7c887e8ec1
1 changed files with 11 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue