diff --git a/lib/extension/bridge.ts b/lib/extension/bridge.ts index fc68f87b07..88d1d89fc0 100644 --- a/lib/extension/bridge.ts +++ b/lib/extension/bridge.ts @@ -434,7 +434,7 @@ export default class Bridge extends Extension { const oldOptions = objectAssignDeep({}, cleanup(entity.options)); if (message.options.icon) { - const base64Match = utils.isBase64File(message.options.icon); + const base64Match = utils.matchBase64File(message.options.icon); if (base64Match) { const fileSettings = utils.saveBase64DeviceIcon(base64Match); message.options.icon = fileSettings; diff --git a/lib/util/settings.ts b/lib/util/settings.ts index 63e08b8981..9a3da3e880 100644 --- a/lib/util/settings.ts +++ b/lib/util/settings.ts @@ -246,7 +246,7 @@ export function validate(): string[] { if (names.includes(e.friendly_name)) errors.push(`Duplicate friendly_name '${e.friendly_name}' found`); errors.push(...utils.validateFriendlyName(e.friendly_name)); names.push(e.friendly_name); - if ('icon' in e && e.icon && !utils.isBase64File(e.icon) && !e.icon.startsWith('device_icons/')) { + if ('icon' in e && e.icon && !utils.matchBase64File(e.icon) && !e.icon.startsWith('device_icons/')) { errors.push(`Device icon of '${e.friendly_name}' should start with 'device_icons/', got '${e.icon}'`); } if (e.qos != null && ![0, 1, 2].includes(e.qos)) { diff --git a/lib/util/settingsMigration.ts b/lib/util/settingsMigration.ts index 7aa45ae1e1..56908fe994 100644 --- a/lib/util/settingsMigration.ts +++ b/lib/util/settingsMigration.ts @@ -460,7 +460,7 @@ function migrateToFour( const [validPath, previousValue] = getValue(currentSettings, ['devices']); for (const deviceKey in currentSettings.devices) { - const base64Match = utils.isBase64File(currentSettings.devices[deviceKey].icon ?? ''); + const base64Match = utils.matchBase64File(currentSettings.devices[deviceKey].icon ?? ''); if (base64Match) { currentSettings.devices[deviceKey].icon = utils.saveBase64DeviceIcon(base64Match); } diff --git a/lib/util/utils.ts b/lib/util/utils.ts index 71d6ba82a9..6b3a6c91c7 100644 --- a/lib/util/utils.ts +++ b/lib/util/utils.ts @@ -375,7 +375,7 @@ function deviceNotCoordinator(device: zh.Device): boolean { return device.type !== 'Coordinator'; } -function isBase64File(value: string): {extension: string; data: string} | false { +function matchBase64File(value: string): {extension: string; data: string} | false { const match = value.match(BASE64_IMAGE_REGEX); if (match) { assert(match.groups?.extension && match.groups?.data); @@ -397,7 +397,7 @@ function saveBase64DeviceIcon(base64Match: {extension: string; data: string}): s const noop = (): void => {}; export default { - isBase64File, + matchBase64File, saveBase64DeviceIcon, capitalize, getZigbee2MQTTVersion,