Address code review findings across relay, UI, and Go backend

- relay: key uploadables map by actual variable name instead of iteration
  index so order-mismatch between Object.keys passes can't desync the
  multipart map from form field names
- mcp/v1: drop dead commented middleware line
- DurationPicker: tighten parse regex to require PT prefix for M/H and P
  for D/W, and reject NaN in stringify so cleared inputs don't produce
  invalid duration strings

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-05-12 14:34:49 +02:00
parent 85c028b537
commit fc24306cd8
3 changed files with 9 additions and 9 deletions

View File

@@ -26,7 +26,7 @@ type Props = {
} & HTMLAttributes<HTMLInputElement>;
const stringify = (value: number | null, unit: string): string | null => {
if (value === null || value <= 0) return null;
if (value === null || !Number.isFinite(value) || value <= 0) return null;
switch (unit) {
case "M":
@@ -43,10 +43,10 @@ const stringify = (value: number | null, unit: string): string | null => {
};
const parse = (value: string): { amount: number; unit: string } => {
const match = value.match(/PT?(\d+)([MDWH])/);
const match = value.match(/^P(?:T(\d+)([MH])|(\d+)([DW]))$/);
if (!match) return { amount: 0, unit: "D" };
const amount = parseInt(match[1], 10) || 0;
const unit = match[2];
const amount = parseInt(match[1] ?? match[3] ?? "0", 10) || 0;
const unit = match[2] ?? match[4] ?? "D";
if (amount % 7 === 0 && unit === "D") {
return { amount: amount / 7, unit: "W" };
}