1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3442 from node-red/dupe-links

Prevent duplicate links being added between nodes
This commit is contained in:
Nick O'Leary 2022-02-14 23:18:01 +00:00 committed by GitHub
commit 3d8505385a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,6 +600,14 @@ RED.nodes = (function() {
RED.events.emit('nodes:add',n);
}
function addLink(l) {
if (nodeLinks[l.source.id]) {
const isUnique = nodeLinks[l.source.id].out.every(function(link) {
return link.sourcePort !== l.sourcePort || link.target.id !== l.target.id
})
if (!isUnique) {
return
}
}
links.push(l);
if (l.source) {
// Possible the node hasn't been added yet