[Sitemap UI] Do not break format defined in label with extra spaces (#3708)

Fix openhab/openhab-webui#1953

Fix a regression introduced by PR #3644

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2023-07-17 17:58:01 +02:00 committed by GitHub
parent 66dec25571
commit f71137331f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -515,7 +515,8 @@ public class ItemUIRegistryImpl implements ItemUIRegistry {
"Item '{}' with unit, nothing allowed after unit in label pattern '{}', dropping postfix",
itemName, pattern);
}
pattern = pattern.substring(0, matcherEnd) + (!unit.isBlank() ? " " + unit : "");
pattern = unit.isBlank() ? pattern.substring(0, matcherEnd)
: pattern.substring(0, pattern.indexOf(unit, matcherEnd) + unit.length());
}
} catch (ItemNotFoundException e) {
logger.warn("Cannot retrieve item '{}' for widget {}", itemName, w.eClass().getInstanceTypeName());