Skip to content

Commit 1bbed72

Browse files
committed
perf(@angular/build): use callback in string replacement to avoid $ interpolation
Use a callback function in String.replace() to prevent special replacement patterns ($&, $', etc.) from being interpreted when a file replacement path contains dollar-sign characters.
1 parent 4aa1c10 commit 1bbed72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/angular/build/src/tools/esbuild/angular/compiler-plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ function applyFileReplacementsToContent(
822822

823823
const newSpecifier = replacementPath.replaceAll('\\', '/');
824824

825-
return match.replace(`${quote}${specifier}${quote}`, `${quote}${newSpecifier}${quote}`);
825+
// Use a callback to avoid special replacement patterns (e.g. `$&`, `$'`) being
826+
// interpreted when the replacement path happens to contain `$` characters.
827+
return match.replace(`${quote}${specifier}${quote}`, () => `${quote}${newSpecifier}${quote}`);
826828
},
827829
);
828830
}

0 commit comments

Comments
 (0)