Skip to content

Commit

Permalink
Fix the position of '@none' while sorting datasetIds
Browse files Browse the repository at this point in the history
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 <meric.feyzullahoglu@gmail.com>
  • Loading branch information
MericFeyz committed May 6, 2024
1 parent d5088e4 commit 8eb5442
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion KafkaBridge/lib/debeziumBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 8eb5442

Please sign in to comment.