From 8eb54426820088c27194bf8a37e058f094e02a90 Mon Sep 17 00:00:00 2001 From: Meric Feyzullahoglu Date: Mon, 6 May 2024 13:32:29 +0000 Subject: [PATCH] Fix the position of '@none' while sorting datasetIds Small improvement to the sorting of datasetIds, which ensures that the datasetId '@none' will always be the first index, even when unsanitized URIs are inputted. Signed-off-by: Meric Feyzullahoglu --- KafkaBridge/lib/debeziumBridge.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/KafkaBridge/lib/debeziumBridge.js b/KafkaBridge/lib/debeziumBridge.js index 319332b8..04b9a40b 100644 --- a/KafkaBridge/lib/debeziumBridge.js +++ b/KafkaBridge/lib/debeziumBridge.js @@ -190,7 +190,11 @@ module.exports = function DebeziumBridge (conf) { counter++; } }); - copyArr.sort((a, b) => a[['https://uri.etsi.org/ngsi-ld/datasetId']].localeCompare(b['https://uri.etsi.org/ngsi-ld/datasetId'])); + copyArr.sort((a, b) => { + if (a['https://uri.etsi.org/ngsi-ld/datasetId'] === '@none' ) return -1; + if (b['https://uri.etsi.org/ngsi-ld/datasetId'] === '@none' ) return 1; + return a['https://uri.etsi.org/ngsi-ld/datasetId'].localeCompare(b['https://uri.etsi.org/ngsi-ld/datasetId']); + }); copyArr.forEach((obj, idx) => { // Index it according to their sorting obj.index = idx; });