Skip to content

fix: broken randImg #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/falso/src/lib/img.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ interface ImgOptions extends FakeOptions {
* @example
*
* randImg({ grayscale: true }) // return a grayscale image (default is false)
*
*
* @example
*
*
* randImg({ random: true }) // default is true, prevent the image from being cached
*
*/
Expand All @@ -56,7 +56,7 @@ export function randImg<Options extends ImgOptions = never>(options?: Options) {
}

return fake(
() => `https://picsum.photos/${width}/${height}${query.toString()}`,
() => `https://picsum.photos/${width}/${height}?${query.toString()}`,
options
);
}
6 changes: 6 additions & 0 deletions packages/falso/src/tests/product.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ describe('productCategory', () => {
expect(typeof product.rating.rate).toEqual('string');
expect(typeof product.rating.count).toEqual('string');
});

it('should return a proper randImg link', () => {
const product = randProduct();

expect(product.image).toContain('?');
});
});