fix sparkplug topic regexp

This commit is contained in:
Björn Dalfors
2024-05-21 15:26:43 +02:00
parent 1f23c65484
commit 97fedcba08

View File

@@ -22,7 +22,7 @@ export interface IDecoder<T = string> {
export const SparkplugDecoder: IDecoder = { export const SparkplugDecoder: IDecoder = {
formats: ['Sparkplug'], formats: ['Sparkplug'],
canDecodeTopic(topic: string) { canDecodeTopic(topic: string) {
return !!topic.match(/spBv1\.0\/[^/]+\/(DDATA|NDATA|NCMD|DCMD|NBIRTH|DBIRTH|NDEATH|DDEATH\/[^/]+\/)/u) return !!topic.match(/^spBv1\.0\/[^/]+\/[ND](DATA|CMD|DEATH|BIRTH)\/[^/]+(\/[^/]+)?$/u)
}, },
decode(input: Base64Message): Base64Message { decode(input: Base64Message): Base64Message {
try { try {