mirror of
https://github.com/traberph/short.git
synced 2026-11-22 22:55:12 +00:00
Allow renaming shortcodes
Shortcodes can now be changed via PATCH /pages/:id with the same validation as on create (format, collisions, reserved root codes, usernames). Stats, link buttons and the homepage pin follow the page. The settings tab shows a warning while editing and asks for confirmation, since the old URL stops working immediately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -106,6 +106,9 @@ export function updatePage(db: Db, actor: Actor, id: number, input: UpdatePageIn
|
||||
if ((input.title !== undefined || input.theme !== undefined) && page.kind !== "linkpage") {
|
||||
throw new HttpError(400, "Only link pages have a title and theme");
|
||||
}
|
||||
if (input.code !== undefined && input.code !== page.code && codeTaken(db, page.namespace, input.code)) {
|
||||
throw new HttpError(409, "Shortcode is not available", { code: ["Already in use or reserved"] });
|
||||
}
|
||||
db.update(pages)
|
||||
.set({ ...input, updatedAt: new Date() })
|
||||
.where(eq(pages.id, id))
|
||||
|
||||
Reference in New Issue
Block a user