Refactor redactor into replacer#2277
Merged
Merged
Conversation
13a2448 to
6ea9be0
Compare
moskyb
reviewed
Aug 8, 2023
| if _, err := r.dst.Write(r.subst); err != nil { | ||
| // Now handle the match itself. | ||
| // Call the replacement callback to get a replacement. | ||
| if repl := r.replacement(r.buf[match.from:match.to]); len(repl) > 0 { |
Contributor
There was a problem hiding this comment.
is "replace the thing matched with an empty string" (ie delete the matched string) a valid use case? i can see the semantics there being a little confusing if the user tried to do that
Contributor
Author
There was a problem hiding this comment.
That should be supported - replacement should return nil. The if on this line is just to skip calling r.dst.Write with nil or empty.
Contributor
Author
|
I'm going to add some more tests, since there is 0 coverage in most of Edit: Done. |
6ea9be0 to
2b08f0d
Compare
triarius
approved these changes
Aug 9, 2023
triarius
left a comment
Contributor
There was a problem hiding this comment.
Nice. I think I know how to use this now.
This was referenced Aug 13, 2023
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes
redactorintoreplacer. A summary:ValuesToRedact, andVarsToRedactare moved into a new package,redactRedactorand necessary friends are renamed and moved intoreplacer.pipeline_upload.gois changed to use aReplacerto search through the JSON in a streaming manner.flushUpTois changed to call a callback when processing matches instead of using a fixed[]byte.flushUpToalso no longer eagerly flushes into the middle of matches.