Open andrefs opened 3 years ago
I would recommend just making a new type. The configuration is going to be more complicated than just making a mongoose.SchemaTypes.NormalizedUrl
. When I made this, I used String
as a base, and you can feel free to use this as a base for yours. As you can see the definition is pretty simple (just a URL-check regex.) You can make it work how you want by making your own type, search & replace for Url
to NormalizedUrl
and re-implementing validateUrl
.
Yes, thank you, that is more or less the solution I implemented.
I was just suggesting that mentioning normalize-url
in mongoose-type-url
's documentation would allow users to expect the URL to be normalized and not getting caught by surprise.
Thanks!
I would be much more "caught by surprise" if the database-type was modifying the URL, and this doesn't seem to be a standard thing at all, so I am hesitant to add it to the docs, as it would be confusing to me if I came across my project made by someone else, and there was stuff about normalize-url
. I can link to your mongoose-type though, if you like. Do you have it on github?
This module uses
normalize-url
, which by default strips (among other things) thewww
from the URLs. I had a use case where I did not want this to happen.I have no idea whether if there is a way for
mongoose-type-url
to receive additional parameters which would be passed on to configurenormalize-url
. If this is not possible, at least referringnormalize-url
in this module's documentation would make it more clear.