[BUG] TypeError during URL validation
Closed this issue · 0 comments
snowteamer commented
Describe the bug
A type error occurs when attempting to save a product object into the db, when the object has URL-valued properties
How to reproduce
let Product = require('./src/models/db/product');
let product = new Product({
name: 'Product',
description: 'The only product we sell currently',
productImageLinks: [
'http://google.no/image.png',
'https://bing.com/image.png'
],
quantityType: 'things',
averageRating: 4.9,
reviewCount: 999,
category: 'Good products',
price: 1.99,
brandName: 'Supreme',
brandLogoLink: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Supreme_Logo.svg/576px-Supreme_Logo.svg.png',
discounts: [
{
name: '90% discount',
type: 'percentage',
value: 90
},
{
name: '2% discount',
type: 'percentage',
value: 2
}
]
});
product.save().then(console.log).catch(console.log);
Expected behavior
No error and the product object should be logged to the console.
Screenshots
Something went wrong trying to upload it :(
Device Information
- OS: Windows 10
- Node version: v14.4.0