Skip to content

Commit

Permalink
Small improvement to the initial name of a device.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-unwin committed Jan 30, 2024
1 parent 3bbfcfa commit c69a4e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Models/DevicesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@ public function create($data = null): ?int
$data->name = '';
}
}
if (strpos($data->name, '.') !== false) {
if (strpos($data->name, '.') !== false and filter_var($data->name, FILTER_VALIDATE_IP) === false) {
// We have a name, not an IP, that contains a 'dot'. Split it and use the first item as the name.
$temp = explode('.', $data->name);
$data->name = $temp[0];
unset($temp);
}
if (empty($data->org_id)) {
$data->org_id = 1;
Expand Down

0 comments on commit c69a4e3

Please sign in to comment.