luci-mod-network: made expandAndFormatMAC return arrays
authorPaul Donald <newtwen+github@gmail.com>
Thu, 25 Jul 2024 14:22:25 +0000 (16:22 +0200)
committerPaul Donald <newtwen+github@gmail.com>
Thu, 25 Jul 2024 14:36:06 +0000 (16:36 +0200)
instead of returning a space separated string

follow-up to 5ab0cb1f15bcb31015ae8345d302c6d023ba51e2

Closes #7209

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
(cherry picked from commit 84ffb655b0764d949c7bd4fd5f9502c314b77c58)

modules/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js

index 66abd8eb65f6900252bdea5c30a06dac779b50f8..8dc77f5e40804aed543dedb96c55aaa776f21522 100644 (file)
@@ -221,7 +221,7 @@ function expandAndFormatMAC(macs) {
                }
        });
 
-       return result.length ? result.join(' ') : null;
+       return result.length ? result : null;
 }
 
 function isValidMAC(sid, s) {
@@ -993,8 +993,12 @@ return view.extend({
                //As a special case, in DHCPv4, it is possible to include more than one hardware address. eg: --dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2 This allows an IP address to be associated with multiple hardware addresses, and gives dnsmasq permission to abandon a DHCP lease to one of the hardware addresses when another one asks for a lease
                so.rmempty  = true;
                so.cfgvalue = function(section) {
-                       var macs = L.toArray(uci.get('dhcp', section, 'mac'));
-                       return expandAndFormatMAC(macs);
+                       var macs = uci.get('dhcp', section, 'mac');
+                       if(!Array.isArray(macs)){
+                               return expandAndFormatMAC(L.toArray(macs));
+                       } else {
+                               return expandAndFormatMAC(macs);
+                       }
                };
                //removed jows renderwidget function which hindered multi-mac entry
                so.validate = validateMACAddr.bind(so, pools);