diff options
Diffstat (limited to 'lib/unitsToRanges.js')
-rw-r--r-- | lib/unitsToRanges.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/unitsToRanges.js b/lib/unitsToRanges.js index 11e867f..cd572f7 100644 --- a/lib/unitsToRanges.js +++ b/lib/unitsToRanges.js @@ -6,10 +6,11 @@ * 1,2,3a-5a => 1-2;3a-5a * * @param {Array} units + * @param {Array} [sourceAddresses] - the source addresses where these units came from, used for debugging * * @returns {string} addr:flats list */ -module.exports = (units) => { +module.exports = (units, sourceAddresses) => { const regexp = /^(?<pre>\D*)(?<num>\d*)(?<suf>\D*)$/ // expand out any existing ranges which may be mixed into the input @@ -30,11 +31,17 @@ module.exports = (units) => { } else { // prefix/suffix don't match in the from-to, so just pass as is console.log(`passed a range with different prefix/suffix: ${rangeParts[0]}-${rangeParts[1]}`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } acc.push(cur) } } else if (rangeParts.length > 2) { // 1-2-3 not sure if this ever occures, but just pass as is console.log(`Unsupported range ${cur}`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } acc.push(cur) } else { // was not a range @@ -65,6 +72,9 @@ module.exports = (units) => { if (!curParts) { console.log(`"${cur}" didn't match regexp for prefix number suffix`) + if (sourceAddresses) { + console.log(JSON.stringify(sourceAddresses, null, 2)) + } return acc } |