validatorjs
validatorjs copied to clipboard
localhost url validation
I noticed that localhost is not valid according to URL validator.
examples url: http://localhost/ http://localhost/deeplink
this is the regex used for validation right now:
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
the following change would fix it:
/https?:\/\/(((www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]{2,63})|(localhost))\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i
I'd appreciate your feedback about it.
in addition, I'd like to know when is expected next release?
Hi. I feel like http://localhost
is not a valid url. You can check it by googling for URL RFC.
Also here is a good comment
My personal opinion is that the current behavior is correct and should not be changed. You may use http://127.0.0.1
Hi @vict-shevchenko , thanks a lot for your comment.
according to the RFC file url is of the following pattern:
"file://" [ host | "localhost" ] "/" fpath
that obviously allows localhost as a the host, In addition, current implementation does not allow IDNs such as http://украина.icom.museum/.
obviously, IDNs also can be worked around with IP, or equivalent Latin version - from UX perspective I believe that both should be supported since both are legal URLs.
Looks like you are right.
Any chances to have it soon? I can create PR that fix it - there is correct Regex: https://github.com/jquery-validation/jquery-validation/blob/a9c20ec280ce3a968abbca5611dcd63f412b5d34/src/core.js#L1408
Any news?
I will get an update posted during holiday break
@mikeerickson any update maybe? :)
@syabro Hey there, my apologies. I thought this had already been fixed, but alas I missed it. I am working on a new build (version 3.23) which I will include this issue.
Fixed in 3.23 release (pending tagging)
Thanks!
@mikeerickson any news? :) 2023 :)