Use null instead of default, to avoid stomping on netmask (#23382)

This commit is contained in:
Mark Steward 2024-12-23 08:22:11 +00:00 committed by GitHub
parent 147098f0fd
commit 7d0a269f1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -117,11 +117,10 @@ export const accesspointScan = async (
};
export const parseAddress = (address: string) => {
const isIPv6 = address.includes(":");
const [ip, cidr] = address.includes("/")
? address.split("/")
: [address, isIPv6 ? "64" : "24"];
return { ip, mask: cidrToNetmask(cidr, isIPv6) };
const [ip, cidr] = address.split("/");
const isIPv6 = ip.includes(":");
const mask = cidr ? cidrToNetmask(cidr, isIPv6) : null;
return { ip, mask };
};
export const formatAddress = (ip: string, mask: string) =>

View File

@ -655,8 +655,14 @@ export class HassioNetwork extends LitElement {
this._dirty = true;
if (id === "address") {
const index = (ev.target as any).index as number;
const { mask: oldMask } = parseAddress(
this._interface![version]!.address![index]
);
const { mask } = parseAddress(value);
this._interface[version]!.address![index] = formatAddress(value, mask);
this._interface[version]!.address![index] = formatAddress(
value,
mask || oldMask || ""
);
this.requestUpdate("_interface");
} else if (id === "netmask") {
const index = (ev.target as any).index as number;