Remove rewrite if match is removed

This commit is contained in:
Owen
2026-03-30 11:11:18 -07:00
parent c995c5a674
commit caacd1e677

View File

@@ -188,6 +188,8 @@ export async function updateTarget(
);
}
const pathMatchTypeRemoved = parsedBody.data.pathMatchType === null;
const [updatedTarget] = await db
.update(targets)
.set({
@@ -200,8 +202,8 @@ export async function updateTarget(
path: parsedBody.data.path,
pathMatchType: parsedBody.data.pathMatchType,
priority: parsedBody.data.priority,
rewritePath: parsedBody.data.rewritePath,
rewritePathType: parsedBody.data.rewritePathType
rewritePath: pathMatchTypeRemoved ? null : parsedBody.data.rewritePath,
rewritePathType: pathMatchTypeRemoved ? null : parsedBody.data.rewritePathType
})
.where(eq(targets.targetId, targetId))
.returning();