preserve port and method on host change

This commit is contained in:
Pallavi
2025-09-01 21:22:18 +05:30
parent 5fcf76066f
commit 5e5754fa62

View File

@@ -649,18 +649,29 @@ export default function ReverseProxyTargets(props: {
defaultValue={row.original.ip} defaultValue={row.original.ip}
className="min-w-[150px]" className="min-w-[150px]"
onBlur={(e) => { onBlur={(e) => {
const parsed = parseHostTarget(e.target.value); const input = e.target.value.trim();
if (parsed) { const hasProtocol = /^https?:\/\//.test(input);
updateTarget(row.original.targetId, { const hasPort = /:\d+/.test(input);
...row.original,
method: parsed.protocol, if (hasProtocol || hasPort) {
ip: parsed.host, const parsed = parseHostTarget(input);
port: parsed.port if (parsed) {
}); updateTarget(row.original.targetId, {
...row.original,
method: hasProtocol ? parsed.protocol : row.original.method,
ip: parsed.host,
port: hasPort ? parsed.port : row.original.port
});
} else {
updateTarget(row.original.targetId, {
...row.original,
ip: input
});
}
} else { } else {
updateTarget(row.original.targetId, { updateTarget(row.original.targetId, {
...row.original, ...row.original,
ip: e.target.value ip: input
}); });
} }
}} }}
@@ -961,11 +972,21 @@ export default function ReverseProxyTargets(props: {
id="ip" id="ip"
{...field} {...field}
onBlur={(e) => { onBlur={(e) => {
const parsed = parseHostTarget(e.target.value); const input = e.target.value.trim();
if (parsed) { const hasProtocol = /^https?:\/\//.test(input);
addTargetForm.setValue("method", parsed.protocol); const hasPort = /:\d+/.test(input);
addTargetForm.setValue("ip", parsed.host);
addTargetForm.setValue("port", parsed.port); if (hasProtocol || hasPort) {
const parsed = parseHostTarget(input);
if (parsed) {
if (hasProtocol || !addTargetForm.getValues("method")) {
addTargetForm.setValue("method", parsed.protocol);
}
addTargetForm.setValue("ip", parsed.host);
if (hasPort || !addTargetForm.getValues("port")) {
addTargetForm.setValue("port", parsed.port);
}
}
} else { } else {
field.onBlur(); field.onBlur();
} }