aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-08-28 09:59:51 -0400
committerGitHub <[email protected]>2022-08-28 15:59:51 +0200
commit379ba79ba3b9735ed039d87f32fc14fa9920d4ed (patch)
treee2ab2bf145231bafc6aaa73ccfdd0124ee3e3c03 /src/modules
parentf78843edb05913c44ebd86535b0d50d22e99fc5e (diff)
downloadfaker-379ba79ba3b9735ed039d87f32fc14fa9920d4ed.tar.xz
faker-379ba79ba3b9735ed039d87f32fc14fa9920d4ed.zip
fix(datatype): unintentional hex breaking change (#1306)
Co-authored-by: Leyla Jähnig <[email protected]>
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/color/index.ts5
-rw-r--r--src/modules/database/index.ts6
-rw-r--r--src/modules/datatype/index.ts14
-rw-r--r--src/modules/finance/index.ts1
-rw-r--r--src/modules/git/index.ts12
5 files changed, 26 insertions, 12 deletions
diff --git a/src/modules/color/index.ts b/src/modules/color/index.ts
index d64b7750..faa898d4 100644
--- a/src/modules/color/index.ts
+++ b/src/modules/color/index.ts
@@ -297,7 +297,10 @@ export class Color {
let color: string | number[];
let cssFunction: CSSFunction = 'rgb';
if (format === 'hex') {
- color = this.faker.datatype.hexadecimal({ length: includeAlpha ? 8 : 6 });
+ color = this.faker.datatype.hexadecimal({
+ length: includeAlpha ? 8 : 6,
+ prefix: '',
+ });
color = formatHexColor(color, options);
return color;
}
diff --git a/src/modules/database/index.ts b/src/modules/database/index.ts
index 5887ab09..69e07315 100644
--- a/src/modules/database/index.ts
+++ b/src/modules/database/index.ts
@@ -69,6 +69,10 @@ export class Database {
* faker.database.mongodbObjectId() // 'e175cac316a79afdd0ad3afb'
*/
mongodbObjectId(): string {
- return this.faker.datatype.hexadecimal({ length: 24, case: 'lower' });
+ return this.faker.datatype.hexadecimal({
+ length: 24,
+ case: 'lower',
+ prefix: '',
+ });
}
}
diff --git a/src/modules/datatype/index.ts b/src/modules/datatype/index.ts
index 671e8c6c..57399450 100644
--- a/src/modules/datatype/index.ts
+++ b/src/modules/datatype/index.ts
@@ -190,17 +190,17 @@ export class Datatype {
*
* @param options The optional options object.
* @param options.length Length of the generated number. Defaults to `1`.
- * @param options.prefix Prefix for the generated number. Defaults to `''`.
+ * @param options.prefix Prefix for the generated number. Defaults to `'0x'`.
* @param options.case Case of the generated number. Defaults to `'mixed'`.
*
* @example
- * faker.datatype.hexadecimal() // 'B'
- * faker.datatype.hexadecimal({ length: 10 }) // 'aE13d044cB'
+ * faker.datatype.hexadecimal() // '0xB'
+ * faker.datatype.hexadecimal({ length: 10 }) // '0xaE13d044cB'
* faker.datatype.hexadecimal({ prefix: '0x' }) // '0xE'
* faker.datatype.hexadecimal({ case: 'lower' }) // 'f'
- * faker.datatype.hexadecimal({ length: 10, prefix: '0x' }) // '0xf12a974eB1'
- * faker.datatype.hexadecimal({ length: 10, case: 'upper' }) // 'E3F38014FB'
- * faker.datatype.hexadecimal({ prefix: '0x', case: 'lower' }) // '0xd'
+ * faker.datatype.hexadecimal({ length: 10, prefix: '#' }) // '#f12a974eB1'
+ * faker.datatype.hexadecimal({ length: 10, case: 'upper' }) // '0xE3F38014FB'
+ * faker.datatype.hexadecimal({ prefix: '', case: 'lower' }) // 'd'
* faker.datatype.hexadecimal({ length: 10, prefix: '0x', case: 'mixed' }) // '0xAdE330a4D1'
*/
hexadecimal(
@@ -220,7 +220,7 @@ export class Datatype {
};
}
- const { length = 1, prefix = '', case: letterCase = 'mixed' } = options;
+ const { length = 1, prefix = '0x', case: letterCase = 'mixed' } = options;
let wholeString = '';
diff --git a/src/modules/finance/index.ts b/src/modules/finance/index.ts
index f1b089e3..c6f79976 100644
--- a/src/modules/finance/index.ts
+++ b/src/modules/finance/index.ts
@@ -323,7 +323,6 @@ export class Finance {
ethereumAddress(): string {
const address = this.faker.datatype.hexadecimal({
length: 40,
- prefix: '0x',
case: 'lower',
});
return address;
diff --git a/src/modules/git/index.ts b/src/modules/git/index.ts
index 21596273..be8d02f1 100644
--- a/src/modules/git/index.ts
+++ b/src/modules/git/index.ts
@@ -92,7 +92,11 @@ export class Git {
* faker.git.commitSha() // '2c6e3880fd94ddb7ef72d34e683cdc0c47bec6e6'
*/
commitSha(): string {
- return this.faker.datatype.hexadecimal({ length: 40, case: 'lower' });
+ return this.faker.datatype.hexadecimal({
+ length: 40,
+ case: 'lower',
+ prefix: '',
+ });
}
/**
@@ -102,6 +106,10 @@ export class Git {
* faker.git.shortSha() // '6155732'
*/
shortSha(): string {
- return this.faker.datatype.hexadecimal({ length: 7, case: 'lower' });
+ return this.faker.datatype.hexadecimal({
+ length: 7,
+ case: 'lower',
+ prefix: '',
+ });
}
}