Skip to content

Commit

Permalink
fix(image): properly add lock= parameter
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
wesen committed Sep 26, 2022
1 parent 526906f commit 9b9f839
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions src/modules/image/index.ts
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand All @@ -111,7 +111,7 @@ export class ImageModule {
}

if (randomize) {
url += `?${this.faker.datatype.number()}`;
url += `?lock=${this.faker.datatype.number()}`;
}

return url;
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand All @@ -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
*/
Expand Down

0 comments on commit 9b9f839

Please sign in to comment.