homieiot / convention

🏡 The Homie Convention: a lightweight MQTT convention for the IoT
https://homieiot.github.io/
Other
705 stars 59 forks source link

chore(id): simplify ID checks #261

Closed Tieske closed 1 year ago

Tieske commented 1 year ago

by removing the constraint that an ID cannot start nor end with a '-', the validation becomes a lot simpler. Eg. in Lua which has a pattern matching engine, but not full regex capabilities, the current ID cannot be validated with a single pattern.

A regex would now simply be ^[a-z0-9-]+$ (or ^$*[a-z0-9-]+$ to match homie-keys), also way easier to implement without a regex engine. Alternatively we could require the ID to be minimum 2 characters in length, which would result in ^[a-z0-9][a-z0-9-]*[a-z0-9]$, which is still fairly simple.

The current limitation is just for human readability, so even if we remove it, it is most unlikely that one would use that anyway. And as mentioned, it is NOT a technical limitation.