Spaces:
Paused
Paused
File size: 441 Bytes
eeb3436 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | const TELEMETRY_TOPIC_REGEX =
/^tenant\/([^/]+)\/truck\/([^/]+)\/container\/([^/]+)\/telemetry$/;
function parseTelemetryTopic(topic) {
if (typeof topic !== "string") {
return null;
}
const match = topic.match(TELEMETRY_TOPIC_REGEX);
if (!match) {
return null;
}
return {
tenantCode: match[1],
truckCode: match[2],
containerCode: match[3],
topic,
};
}
module.exports = {
parseTelemetryTopic,
};
|