Skip to content

Commit

Permalink
fix(web): proper handle of the network prefix (#1728)
Browse files Browse the repository at this point in the history
## Problem

The web UI crashes when you try to edit a network connection containing
an additional IP address
because the prefix is not handled correctly. The `as string`
construction tells TypeScript to
consider the variable as a string, but it does not do a runtime
conversion.

## Solution

Cast the variable to a string at runtime.
  • Loading branch information
imobachgs authored Nov 5, 2024
2 parents 233f705 + 32d38bd commit 5b4f014
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
-------------------------------------------------------------------
Mon Nov 04 20:32:29 UTC 2024 - David Diaz <[email protected]>
Tue Nov 5 11:33:12 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

- Fix a crash when editing a network connection containing an
additional IP address (gh#agama-project/agama#1728).

-------------------------------------------------------------------
Mon Nov 4 20:32:29 UTC 2024 - David Diaz <[email protected]>

- Add missing subscription to avoid Agama getting stuck at the installation
progress when the installation finishes
Expand Down
2 changes: 1 addition & 1 deletion web/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const isValidIp = (value: IPAddress["address"]) => ipaddr.IPv4.isValidFourPartDe
* @return true if given IP is valid; false otherwise.
*/
const isValidIpPrefix = (value: IPAddress["prefix"]) => {
const prefix = value as string;
const prefix = String(value);

if (prefix.match(/^\d+$/)) {
return parseInt(prefix) <= 32;
Expand Down

0 comments on commit 5b4f014

Please sign in to comment.