mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
Allow placeholder images for products and line items without images
This commit is contained in:
15
framework/spree/utils/validate-placeholder-image-url.ts
Normal file
15
framework/spree/utils/validate-placeholder-image-url.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
const validatePlaceholderImageUrl = (
|
||||
placeholderUrlOrFalse: unknown
|
||||
): string | false => {
|
||||
if (!placeholderUrlOrFalse || placeholderUrlOrFalse === 'false') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof placeholderUrlOrFalse === 'string') {
|
||||
return placeholderUrlOrFalse
|
||||
}
|
||||
|
||||
throw new TypeError('placeholderUrlOrFalse must be a string or falsy.')
|
||||
}
|
||||
|
||||
export default validatePlaceholderImageUrl
|
Reference in New Issue
Block a user