Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 1x 1x 67x 67x 67x 285x 93x 285x 282x 93x 93x 42x 42x 42x 42x 41x 41x 41x 51x 92x 66x | 'use strict'
const rx = require('./rx')
module.exports = parse
function parse ({paths, censor}) {
const wildcards = []
var wcLen = 0
const secret = paths.reduce(function (o, strPath) {
var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ''))
path = path.map((p) => {
if (p[0] === '[') return p.substr(1, p.length - 2)
else return p
})
const star = path.indexOf('*')
if (star > -1) {
const before = path.slice(0, star)
const beforeStr = before.join('.')
const after = path.slice(star + 1, path.length)
if (after.indexOf('*') > -1) throw Error('fast-redact – Only one wildcard per path is supported')
const nested = after.length > 0
wcLen++
wildcards.push({
before,
beforeStr,
after,
nested
})
} else {
o[strPath] = {
path: path,
val: null,
precensored: false,
circle: '',
escPath: JSON.stringify(strPath)
}
}
return o
}, {})
return { wildcards, wcLen, secret }
}
|