Twaha-Rahman/e-commercify

[REQUEST] URL validation in Mongoose

Closed this issue · 2 comments

Is your feature request related to a problem? Please describe.
Apparently the regex isn't perfect for URL validation. Someone recommended using a third-party module to validate since it might be more correct.

Describe the solution you would like
I do think it might be problematic to add a URL validator module into a Mongoose schema. It is possible to validate the URL before passing the value into Mongoose. I believe the safest thing to do might be regex.

Maybe we don't need to store fully qualified URLs in the DB, but only "leaf-node" file paths like apple-ff123.png, relative to one or more root URLs which would be stored in a separate collection.

Like in this example: https://mongoosejs.com/docs/schematypes.html#getters

Maybe we don't need to store fully qualified URLs in the DB, but only "leaf-node" file paths like apple-ff123.png, relative to one or more root URLs which would be stored in a separate collection.

Like in this example: https://mongoosejs.com/docs/schematypes.html#getters

@snowteamer I agree. The folder structure should be in the .env. We should just save the filename.