diff options
Diffstat (limited to 'src/modules/internet')
| -rw-r--r-- | src/modules/internet/index.ts | 10 | ||||
| -rw-r--r-- | src/modules/internet/user-agent.ts | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts index 2bac0668..8f5cc8bb 100644 --- a/src/modules/internet/index.ts +++ b/src/modules/internet/index.ts @@ -33,6 +33,7 @@ export class InternetModule { if (name === 'constructor' || typeof this[name] !== 'function') { continue; } + this[name] = this[name].bind(this); } } @@ -173,10 +174,12 @@ export class InternetModule { if (charMapping[char]) { return charMapping[char]; } + if (char.charCodeAt(0) < 0x80) { // Keep ASCII characters return char; } + // Final fallback return the Unicode char code value for Chinese, Japanese, Korean etc, base-36 encoded return char.charCodeAt(0).toString(36); }) @@ -224,6 +227,7 @@ export class InternetModule { ])}${lastName}${this.faker.number.int(99)}`; break; } + result = result.toString().replace(/'/g, ''); result = result.replace(/ /g, ''); return result; @@ -493,6 +497,7 @@ export class InternetModule { mac += validSep; } } + return mac; } @@ -536,6 +541,7 @@ export class InternetModule { if (prefix.length >= length) { return prefix; } + if (memorable) { if (prefix.match(consonant)) { pattern = vowel; @@ -543,16 +549,20 @@ export class InternetModule { pattern = consonant; } } + const n = this.faker.number.int(94) + 33; let char = String.fromCharCode(n); if (memorable) { char = char.toLowerCase(); } + if (!char.match(pattern)) { return _password(length, memorable, pattern, prefix); } + return _password(length, memorable, pattern, prefix + char); }; + return _password(len, memorable, pattern, prefix); } diff --git a/src/modules/internet/user-agent.ts b/src/modules/internet/user-agent.ts index 005e31e6..40bc025f 100644 --- a/src/modules/internet/user-agent.ts +++ b/src/modules/internet/user-agent.ts @@ -70,6 +70,7 @@ export function generate(faker: Faker): string { if (rand >= min && rand <= max) { break; } + min = min + obj[key]; } } @@ -219,6 +220,7 @@ export function generate(faker: Faker): string { for (let x = 0; x < dots; x++) { return_val += `.${faker.string.numeric({ allowLeadingZeros: true })}`; } + return return_val; }; |
