mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #3442 from node-red/dupe-links
Prevent duplicate links being added between nodes
This commit is contained in:
		| @@ -600,6 +600,14 @@ RED.nodes = (function() { | |||||||
|         RED.events.emit('nodes:add',n); |         RED.events.emit('nodes:add',n); | ||||||
|     } |     } | ||||||
|     function addLink(l) { |     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); |         links.push(l); | ||||||
|         if (l.source) { |         if (l.source) { | ||||||
|             // Possible the node hasn't been added yet |             // Possible the node hasn't been added yet | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user