Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize replacement values does not work. #34

Open
pbeets opened this issue Sep 11, 2019 · 2 comments · May be fixed by #78
Open

Customize replacement values does not work. #34

pbeets opened this issue Sep 11, 2019 · 2 comments · May be fixed by #78

Comments

@pbeets
Copy link

pbeets commented Sep 11, 2019

I'm unable to get the builtInRedactors replacement values override to work. Even just entering in the example does not work.

Here is another example using the AsyncRedactor.

const { AsyncRedactor } = require('redact-pii')
const redactor = new AsyncRedactor({ builtInRedactors: { ipAddress: { replaceWith: '{{IP_ADDRESS}}' } } })

redactor.redactAsync('192.168.0.1')
// Outputs Promise { 'IP_ADDRESS' }

@jwill20
Copy link

jwill20 commented Sep 19, 2019

I have the same issue.

@cwingrav
Copy link

cwingrav commented Nov 22, 2019

It looks like the generated code in file composition.js is wrong:

if (!opts.builtInRedactors || !opts.builtInRedactors.names || opts.builtInRedactors.names.enabled !== false) {
          childRedactors.push(new NameRedactor_1.NameRedactor(opts.globalReplaceWith));
      }

Looks like it instead means to do this? I'm guessing at their intent here where it uses global by default or when names.enabled == true. Other cases, use names.replaceWith:

if (! opts.buildInRedactors ) { 
      childRedactors.push(new NameRedactor_1.NameRedactor(opts.globalReplaceWith));
    } 
    else if ( opts.builtInRedactors.names && opts.builtInRedactors.names.enabled === true ) {
      childRedactors.push(new NameRedactor_1.NameRedactor(opts.globalReplaceWith));
    }
    else if ( opts.builtInRedactors.names && opts.builtInRedactors.names.replaceWith !== undefined ) {
      childRedactors.push(new NameRedactor_1.NameRedactor(opts.builtInRedactors.names.replaceWith));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants