diff options
| author | ST-DDT <[email protected]> | 2024-12-28 04:24:51 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-28 03:24:51 +0000 |
| commit | 817f8a01d93378e00c03cf73154fcec34fd5feef (patch) | |
| tree | 38f8ec48b1a5332b78c3a5611f07bd2d370651c5 /src | |
| parent | ad8b3604743bf4f1616752cf4f0a9af8278a4e25 (diff) | |
| download | faker-817f8a01d93378e00c03cf73154fcec34fd5feef.tar.xz faker-817f8a01d93378e00c03cf73154fcec34fd5feef.zip | |
fix: basic wildcard range handling + add more tests (#3322)
* fix: basic wirdcard range handling + add more tests
* chore: simplify lower/upper case conversion
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/helpers/index.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/helpers/index.ts b/src/modules/helpers/index.ts index 473927c3..6bb7e1ba 100644 --- a/src/modules/helpers/index.ts +++ b/src/modules/helpers/index.ts @@ -394,9 +394,21 @@ export class SimpleHelpersModule extends SimpleModuleBase { quantifierMax ); + let replacement: string; + if (token[1] === '.') { + replacement = this.faker.string.alphanumeric(repetitions); + } else if (isCaseInsensitive) { + replacement = this.faker.string.fromCharacters( + [token[1].toLowerCase(), token[1].toUpperCase()], + repetitions + ); + } else { + replacement = token[1].repeat(repetitions); + } + pattern = pattern.slice(0, token.index) + - token[1].repeat(repetitions) + + replacement + pattern.slice(token.index + token[0].length); token = SINGLE_CHAR_REG.exec(pattern); } |
