bnoguchi / mongoose-types

Additional handy types for mongoose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URLs getting butchered. :(

Qard opened this issue · comments

Tried using mongoose-types for URL matching, but it's butchering my URLs. Not particularly liking the edits it's doing. It keeps removing the port number and adding question marks to the end of every URL. >.>

I don't use mongoose-types anymore. I use the following as my validators

var Url = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
var Email = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

I have the same issue :(

It adds the question mark at the end due to an incorrect check on url.js, line 52. Even if the query string is empty, the check returns true since url parsing returns an object literal, which evaluates to true.