Fix missing-host highlight flagging regexes after a comma or 'or' separator
This commit is contained in:
parent
63177a9573
commit
7c385bef64
2 changed files with 12 additions and 3 deletions
|
|
@ -5,6 +5,11 @@ All notable changes to **Checkmk SwissKnife** are documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [2.24.1] - 2026-09-30
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Missing-host highlighting no longer flags regexes that follow a comma or an "or" in a "Host name matches one of regex A, B or C" condition as host names.
|
||||||
|
|
||||||
## [2.24.0] - 2026-09-28
|
## [2.24.0] - 2026-09-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Checkmk SwissKnife
|
// @name Checkmk SwissKnife
|
||||||
// @namespace https://luigidacunto.com/
|
// @namespace https://luigidacunto.com/
|
||||||
// @version 2.24.0
|
// @version 2.24.1
|
||||||
// @checkmk 2.3.x - 2.4.x
|
// @checkmk 2.3.x - 2.4.x
|
||||||
// @description Collection of UI improvements for Checkmk WATO. Each fix or enhancement is added here as an independent feature.
|
// @description Collection of UI improvements for Checkmk WATO. Each fix or enhancement is added here as an independent feature.
|
||||||
// @author Luigi D'Acunto
|
// @author Luigi D'Acunto
|
||||||
|
|
@ -913,10 +913,14 @@
|
||||||
|
|
||||||
items.forEach(li => {
|
items.forEach(li => {
|
||||||
if (!li.textContent.trim().startsWith('Host name')) return;
|
if (!li.textContent.trim().startsWith('Host name')) return;
|
||||||
|
let isRegex = false;
|
||||||
li.querySelectorAll('b').forEach(b => {
|
li.querySelectorAll('b').forEach(b => {
|
||||||
// Text right before each <b> tells regex ("matches regex", "one of regex") from exact name ("is", "is not")
|
// Text right before each <b> tells regex ("matches regex", "one of regex") from exact name ("is", "is not").
|
||||||
|
// A bare "," / " or " separator continues the previous mode: "matches regex A or B" → B is a regex too.
|
||||||
const before = b.previousSibling ? b.previousSibling.textContent : '';
|
const before = b.previousSibling ? b.previousSibling.textContent : '';
|
||||||
if (/regex/.test(before) || b.querySelector('a')) return;
|
if (/regex/.test(before)) isRegex = true;
|
||||||
|
else if (!/^[\s,]*(or)?[\s,]*$/.test(before)) isRegex = false;
|
||||||
|
if (isRegex || b.querySelector('a')) return;
|
||||||
b.classList.add('cmk-sk-missing-host');
|
b.classList.add('cmk-sk-missing-host');
|
||||||
b.title = 'Host not found in Checkmk (deleted?)';
|
b.title = 'Host not found in Checkmk (deleted?)';
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue