aboutsummaryrefslogtreecommitdiff
path: root/src/modules/internet
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-11-23 20:03:32 +0100
committerGitHub <[email protected]>2023-11-23 20:03:32 +0100
commit9b00fe9f7353df50c67966141a5f024ec9b95208 (patch)
tree685ac4468b0e89855ef5f8fe45f299f2b3416080 /src/modules/internet
parentaff0f8022d30a132a6945efac44c22688b5fb5b8 (diff)
downloadfaker-9b00fe9f7353df50c67966141a5f024ec9b95208.tar.xz
faker-9b00fe9f7353df50c67966141a5f024ec9b95208.zip
infra(unicorn): prefer-code-point (#2509)
Diffstat (limited to 'src/modules/internet')
-rw-r--r--src/modules/internet/index.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/modules/internet/index.ts b/src/modules/internet/index.ts
index 8367825f..395266fb 100644
--- a/src/modules/internet/index.ts
+++ b/src/modules/internet/index.ts
@@ -660,13 +660,15 @@ export class InternetModule extends ModuleBase {
return charMapping[char];
}
- if (char.charCodeAt(0) < 0x80) {
+ const charCode = char.codePointAt(0) ?? Number.NaN;
+
+ if (charCode < 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);
+ return charCode.toString(36);
})
.join('');
result = result.toString().replace(/'/g, '');
@@ -1495,7 +1497,7 @@ export class InternetModule extends ModuleBase {
}
const n = this.faker.number.int(94) + 33;
- let char = String.fromCharCode(n);
+ let char = String.fromCodePoint(n);
if (memorable) {
char = char.toLowerCase();
}