aboutsummaryrefslogtreecommitdiff
path: root/src/image.ts
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-01-30 19:37:21 +0100
committerGitHub <[email protected]>2022-01-30 19:37:21 +0100
commit6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a (patch)
tree7b043e25d6fe971c3223851b2ccac8338e51d8a8 /src/image.ts
parentd4125e2a7d69042c37ccecea89f1525c4424a45b (diff)
downloadfaker-6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a.tar.xz
faker-6c5b9706eb16f8841d3f3b2109b8a21fb65fa04a.zip
chore: use recommended restrict-plus-operands (#369)
Diffstat (limited to 'src/image.ts')
-rw-r--r--src/image.ts25
1 files changed, 7 insertions, 18 deletions
diff --git a/src/image.ts b/src/image.ts
index 00e94114..1a74f26e 100644
--- a/src/image.ts
+++ b/src/image.ts
@@ -87,13 +87,13 @@ export class Image {
if (typeof https !== 'undefined' && https === true) {
protocol = 'https://';
}
- let url = protocol + 'placeimg.com/' + width + '/' + height;
+ let url = `${protocol}placeimg.com/${width}/${height}`;
if (typeof category !== 'undefined') {
url += '/' + category;
}
if (randomize) {
- url += '?' + this.faker.datatype.number();
+ url += `?${this.faker.datatype.number()}`;
}
return url;
@@ -264,22 +264,11 @@ export class Image {
* @param color
*/
dataUri(width?: number, height?: number, color: string = 'grey'): string {
- const svgString =
- '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="' +
- width +
- '" height="' +
- height +
- '"><rect width="100%" height="100%" fill="' +
- color +
- '"/><text x="' +
- width / 2 +
- '" y="' +
- height / 2 +
- '" font-size="20" alignment-baseline="middle" text-anchor="middle" fill="white">' +
- width +
- 'x' +
- height +
- '</text></svg>';
+ const svgString = `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="${width}" height="${height}"><rect width="100%" height="100%" fill="${color}"/><text x="${
+ width / 2
+ }" y="${
+ height / 2
+ }" font-size="20" alignment-baseline="middle" text-anchor="middle" fill="white">${width}x${height}</text></svg>`;
const rawPrefix = 'data:image/svg+xml;charset=UTF-8,';
return rawPrefix + encodeURIComponent(svgString);
}