update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
45
node_modules/fast-redact/lib/parse.js
generated
vendored
Normal file
45
node_modules/fast-redact/lib/parse.js
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
'use strict'
|
||||
|
||||
const rx = require('./rx')
|
||||
|
||||
module.exports = parse
|
||||
|
||||
function parse ({ paths }) {
|
||||
const wildcards = []
|
||||
var wcLen = 0
|
||||
const secret = paths.reduce(function (o, strPath, ix) {
|
||||
var path = strPath.match(rx).map((p) => p.replace(/'|"|`/g, ''))
|
||||
const leadingBracket = strPath[0] === '['
|
||||
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: undefined,
|
||||
precensored: false,
|
||||
circle: '',
|
||||
escPath: JSON.stringify(strPath),
|
||||
leadingBracket: leadingBracket
|
||||
}
|
||||
}
|
||||
return o
|
||||
}, {})
|
||||
|
||||
return { wildcards, wcLen, secret }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue