fix(process): normalize scenario replacements literally
capture_process_scenario declares normalization patterns as literal text, but\nreplaceAll expands \$&\, \$\`, and \$1\ in the replacement as a replacement\npattern. A caller normalizing text that contains a dollar sign silently gets\nduplicated, spliced, or dropped content in the recorded Evidence instead of\nthe requested literal replacement.\n\nUse split/join, which is literal on both sides and is already the idiom used\nfor exact-literal scenario rules in browserScenarioNormalization.ts.
This commit is contained in:
@@ -71,6 +71,30 @@ const scenario = (normalization: {
|
||||
},
|
||||
});
|
||||
|
||||
it("replaces caller-declared patterns literally, without expanding replacement patterns", () => {
|
||||
const declared = parseProcessScenario({
|
||||
executable: "/usr/bin/node",
|
||||
working_directory: "/workspace",
|
||||
normalization: {
|
||||
paths: false,
|
||||
time_bucket_ms: 10,
|
||||
patterns: [
|
||||
{ pattern: "8080", replacement: "$&$&" },
|
||||
{ pattern: "READY", replacement: "$$" },
|
||||
{ pattern: "NAME", replacement: "$1" },
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(
|
||||
normalizeProcessText(
|
||||
"listening on 8080; READY; NAME=alpha; tail NAME",
|
||||
declared,
|
||||
"/temporary",
|
||||
rootPid,
|
||||
),
|
||||
).toBe("listening on $&$&; $$; $1=alpha; tail $1");
|
||||
});
|
||||
|
||||
it("preserves compact JSON, counters, line numbers, and ambiguous endpoint spellings", () => {
|
||||
const input = [
|
||||
'{"pid":32,"size":108,"height":480,"width":640,"score":20}',
|
||||
|
||||
Reference in New Issue
Block a user