diff options
-rw-r--r-- | lib/unitsToRanges.js | 2 | ||||
-rw-r--r-- | test/unitsToRanges.js | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/unitsToRanges.js b/lib/unitsToRanges.js index cd572f7..e73388a 100644 --- a/lib/unitsToRanges.js +++ b/lib/unitsToRanges.js @@ -54,7 +54,7 @@ module.exports = (units, sourceAddresses) => { const existingRanges = [] // adapted from https://stackoverflow.com/a/54973116/6702659 - const formedRanges = expandedUnits + const formedRanges = [...new Set(expandedUnits)] .slice() .map(unit => { if (unit.split('-').length > 1) { diff --git a/test/unitsToRanges.js b/test/unitsToRanges.js index 2702b4a..7183ad1 100644 --- a/test/unitsToRanges.js +++ b/test/unitsToRanges.js @@ -87,5 +87,17 @@ test('units list to addr:flats', t => { 'different prefix not merged' ) + t.same( + unitsToRanges(['1', '1']), + '1', + 'source duplicates removed' + ) + + t.same( + unitsToRanges(['1', '1-2']), + '1-2', + 'source duplicates removed with range' + ) + t.end() }) |