fix(process)!: version literal scenario replacement semantics
Keep caller-selected replacement text literal with a callback, preserving empty-search positions instead of changing their split/join behavior. Commit the replacement interpretation for captures using custom patterns so legacy records cannot report this producer correction as a target change. BREAKING CHANGE: Captures with custom normalization patterns use literal-replacements-v1 and cannot be compared with legacy unversioned pattern captures. Capture both sides with the same replacement semantics; legacy captures remain readable and captures without patterns are unaffected.
This commit is contained in:
@@ -34,11 +34,13 @@ export const normalizeProcessText = (
|
||||
normalized = normalizePortTokens(normalized);
|
||||
if (scenario.normalization.pids)
|
||||
normalized = normalizePidTokens(normalized, [pid]);
|
||||
// Scenario replacements are literal text, so `$&`, `` $` ``, and `$1` must
|
||||
// reach the captured output verbatim instead of expanding as a replacement
|
||||
// pattern. split/join is literal on both sides.
|
||||
// A callback keeps replacement text literal while preserving replaceAll's
|
||||
// empty-pattern boundaries, which the process scenario contract permits.
|
||||
for (const pattern of scenario.normalization.patterns)
|
||||
normalized = normalized.split(pattern.pattern).join(pattern.replacement);
|
||||
normalized = normalized.replaceAll(
|
||||
pattern.pattern,
|
||||
() => pattern.replacement,
|
||||
);
|
||||
return normalized;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user