diff options
| author | Shinigami <[email protected]> | 2023-03-20 20:04:02 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-03-20 19:04:02 +0000 |
| commit | 241d11d0a0b86a10bc840ce574b3f6022b9177ee (patch) | |
| tree | e32fe8a7df7acbd63888b08ad319e4de7aebf5fd /src/modules | |
| parent | 93e1433b92c69331349e9feccdf57b84a82a2555 (diff) | |
| download | faker-241d11d0a0b86a10bc840ce574b3f6022b9177ee.tar.xz faker-241d11d0a0b86a10bc840ce574b3f6022b9177ee.zip | |
test(helpers): mustache special cases (#1875)
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/helpers/index.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index b3d4bce9..cfb1ea36 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -400,8 +400,10 @@ export class HelpersModule { for (const p in data) { const re = new RegExp(`{{${p}}}`, 'g'); - const value = data[p]; + let value = data[p]; if (typeof value === 'string') { + // escape $, source: https://stackoverflow.com/a/6969486/6897682 + value = value.replace(/\$/g, '$$$$'); str = str.replace(re, value); } else { str = str.replace(re, value); |
