From 9b9f839715584cf55e89db20930f2668fdfa245e Mon Sep 17 00:00:00 2001 From: Manuel Odendahl Date: Mon, 26 Sep 2022 14:32:57 -0400 Subject: [PATCH] fix(image): properly add lock= parameter https://loremflickr.com requires the lock= parameter to be given to serve an identical image (at least as long as its cache is not updated). --- src/modules/image/index.ts | 94 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/modules/image/index.ts b/src/modules/image/index.ts index 1a709505da9..ffca96cce1c 100644 --- a/src/modules/image/index.ts +++ b/src/modules/image/index.ts @@ -39,9 +39,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.image() // 'https://loremflickr.com/640/480/city' - * faker.image.image(1234, 2345) // 'https://loremflickr.com/1234/2345/sports' - * faker.image.image(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?56789' + * faker.image.image() // 'https://loremflickr.com/640/480/city?lock=0' + * faker.image.image(1234, 2345) // 'https://loremflickr.com/1234/2345/sports?lock=0' + * faker.image.image(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789' * * @since 2.0.1 */ @@ -90,10 +90,10 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.imageUrl() // 'https://loremflickr.com/640/480' - * faker.image.imageUrl(1234, 2345) // 'https://loremflickr.com/1234/2345' - * faker.image.imageUrl(1234, 2345, 'cat') // 'https://loremflickr.com/1234/2345/cat' - * faker.image.imageUrl(1234, 2345, 'cat', true) // 'https://loremflickr.com/1234/2345/cat?6849' + * faker.image.imageUrl() // 'https://loremflickr.com/640/480?lock=0' + * faker.image.imageUrl(1234, 2345) // 'https://loremflickr.com/1234/2345?lock=0' + * faker.image.imageUrl(1234, 2345, 'cat') // 'https://loremflickr.com/1234/2345/cat?lock=0' + * faker.image.imageUrl(1234, 2345, 'cat', true) // 'https://loremflickr.com/1234/2345/cat?lock=6849' * * @since 2.0.1 */ @@ -111,7 +111,7 @@ export class ImageModule { } if (randomize) { - url += `?${this.faker.datatype.number()}`; + url += `?lock=${this.faker.datatype.number()}`; } return url; @@ -125,9 +125,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.abstract() // 'https://loremflickr.com/640/480/abstract' - * faker.image.abstract(1234, 2345) // 'https://loremflickr.com/1234/2345/abstract' - * faker.image.abstract(1234, 2345, true) // 'https://loremflickr.com/1234/2345/abstract?56789' + * faker.image.abstract() // 'https://loremflickr.com/640/480/abstract?lock=0' + * faker.image.abstract(1234, 2345) // 'https://loremflickr.com/1234/2345/abstract?lock=0' + * faker.image.abstract(1234, 2345, true) // 'https://loremflickr.com/1234/2345/abstract?lock=56789' * * @since 2.0.1 */ @@ -143,9 +143,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.animals() // 'https://loremflickr.com/640/480/animals' - * faker.image.animals(1234, 2345) // 'https://loremflickr.com/1234/2345/animals' - * faker.image.animals(1234, 2345, true) // 'https://loremflickr.com/1234/2345/animals?56789' + * faker.image.animals() // 'https://loremflickr.com/640/480/animals?lock=0' + * faker.image.animals(1234, 2345) // 'https://loremflickr.com/1234/2345/animals?lock=0' + * faker.image.animals(1234, 2345, true) // 'https://loremflickr.com/1234/2345/animals?lock=56789' * * @since 2.0.1 */ @@ -161,9 +161,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.business() // 'https://loremflickr.com/640/480/business' - * faker.image.business(1234, 2345) // 'https://loremflickr.com/1234/2345/business' - * faker.image.business(1234, 2345, true) // 'https://loremflickr.com/1234/2345/business?56789' + * faker.image.business() // 'https://loremflickr.com/640/480/business?lock=0' + * faker.image.business(1234, 2345) // 'https://loremflickr.com/1234/2345/business?lock=0' + * faker.image.business(1234, 2345, true) // 'https://loremflickr.com/1234/2345/business?lock=56789' * * @since 2.0.1 */ @@ -179,9 +179,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.cats() // 'https://loremflickr.com/640/480/cats' - * faker.image.cats(1234, 2345) // 'https://loremflickr.com/1234/2345/cats' - * faker.image.cats(1234, 2345, true) // 'https://loremflickr.com/1234/2345/cats?56789' + * faker.image.cats() // 'https://loremflickr.com/640/480/cats?lock=0' + * faker.image.cats(1234, 2345) // 'https://loremflickr.com/1234/2345/cats?lock=0' + * faker.image.cats(1234, 2345, true) // 'https://loremflickr.com/1234/2345/cats?lock=56789' * * @since 2.0.1 */ @@ -197,9 +197,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.city() // 'https://loremflickr.com/640/480/city' - * faker.image.city(1234, 2345) // 'https://loremflickr.com/1234/2345/city' - * faker.image.city(1234, 2345, true) // 'https://loremflickr.com/1234/2345/city?56789' + * faker.image.city() // 'https://loremflickr.com/640/480/city?lock=0' + * faker.image.city(1234, 2345) // 'https://loremflickr.com/1234/2345/city?lock=0' + * faker.image.city(1234, 2345, true) // 'https://loremflickr.com/1234/2345/city?lock=56789' * * @since 2.0.1 */ @@ -215,9 +215,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.food() // 'https://loremflickr.com/640/480/food' - * faker.image.food(1234, 2345) // 'https://loremflickr.com/1234/2345/food' - * faker.image.food(1234, 2345, true) // 'https://loremflickr.com/1234/2345/food?56789' + * faker.image.food() // 'https://loremflickr.com/640/480/food?lock=0' + * faker.image.food(1234, 2345) // 'https://loremflickr.com/1234/2345/food?lock=0' + * faker.image.food(1234, 2345, true) // 'https://loremflickr.com/1234/2345/food?lock=56789' * * @since 2.0.1 */ @@ -233,9 +233,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.nightlife() // 'https://loremflickr.com/640/480/nightlife' - * faker.image.nightlife(1234, 2345) // 'https://loremflickr.com/1234/2345/nightlife' - * faker.image.nightlife(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nightlife?56789' + * faker.image.nightlife() // 'https://loremflickr.com/640/480/nightlife?lock=0' + * faker.image.nightlife(1234, 2345) // 'https://loremflickr.com/1234/2345/nightlife?lock=0' + * faker.image.nightlife(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nightlife?lock=56789' * * @since 2.0.1 */ @@ -251,9 +251,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.fashion() // 'https://loremflickr.com/640/480/fashion' - * faker.image.fashion(1234, 2345) // 'https://loremflickr.com/1234/2345/fashion' - * faker.image.fashion(1234, 2345, true) // 'https://loremflickr.com/1234/2345/fashion?56789' + * faker.image.fashion() // 'https://loremflickr.com/640/480/fashion?lock=0' + * faker.image.fashion(1234, 2345) // 'https://loremflickr.com/1234/2345/fashion?lock=0' + * faker.image.fashion(1234, 2345, true) // 'https://loremflickr.com/1234/2345/fashion?lock=56789' * * @since 2.0.1 */ @@ -269,9 +269,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.people() // 'https://loremflickr.com/640/480/people' - * faker.image.people(1234, 2345) // 'https://loremflickr.com/1234/2345/people' - * faker.image.people(1234, 2345, true) // 'https://loremflickr.com/1234/2345/people?56789' + * faker.image.people() // 'https://loremflickr.com/640/480/people?lock=0' + * faker.image.people(1234, 2345) // 'https://loremflickr.com/1234/2345/people?lock=0' + * faker.image.people(1234, 2345, true) // 'https://loremflickr.com/1234/2345/people?lock=56789' * * @since 2.0.1 */ @@ -287,9 +287,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.nature() // 'https://loremflickr.com/640/480/nature' - * faker.image.nature(1234, 2345) // 'https://loremflickr.com/1234/2345/nature' - * faker.image.nature(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?56789' + * faker.image.nature() // 'https://loremflickr.com/640/480/nature?lock=0' + * faker.image.nature(1234, 2345) // 'https://loremflickr.com/1234/2345/nature?lock=0' + * faker.image.nature(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789' * * @since 2.0.1 */ @@ -305,9 +305,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.sports() // 'https://loremflickr.com/640/480/sports' - * faker.image.sports(1234, 2345) // 'https://loremflickr.com/1234/2345/sports' - * faker.image.sports(1234, 2345, true) // 'https://loremflickr.com/1234/2345/sports?56789' + * faker.image.sports() // 'https://loremflickr.com/640/480/sports?lock=0' + * faker.image.sports(1234, 2345) // 'https://loremflickr.com/1234/2345/sports?lock=0' + * faker.image.sports(1234, 2345, true) // 'https://loremflickr.com/1234/2345/sports?lock=56789' * * @since 2.0.1 */ @@ -323,9 +323,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.technics() // 'https://loremflickr.com/640/480/technics' - * faker.image.technics(1234, 2345) // 'https://loremflickr.com/1234/2345/technics' - * faker.image.technics(1234, 2345, true) // 'https://loremflickr.com/1234/2345/technics?56789' + * faker.image.technics() // 'https://loremflickr.com/640/480/technics?lock=0' + * faker.image.technics(1234, 2345) // 'https://loremflickr.com/1234/2345/technics?lock=0' + * faker.image.technics(1234, 2345, true) // 'https://loremflickr.com/1234/2345/technics?lock=56789' * * @since 2.0.1 */ @@ -341,9 +341,9 @@ export class ImageModule { * @param randomize Whether to randomize the image or not. Defaults to `false`. * * @example - * faker.image.transport() // 'https://loremflickr.com/640/480/transport' - * faker.image.transport(1234, 2345) // 'https://loremflickr.com/1234/2345/transport' - * faker.image.transport(1234, 2345, true) // 'https://loremflickr.com/1234/2345/transport?56789' + * faker.image.transport() // 'https://loremflickr.com/640/480/transport?lock=0' + * faker.image.transport(1234, 2345) // 'https://loremflickr.com/1234/2345/transport?lock=0' + * faker.image.transport(1234, 2345, true) // 'https://loremflickr.com/1234/2345/transport?lock=56789' * * @since 2.0.1 */