validatorjs icon indicating copy to clipboard operation
validatorjs copied to clipboard

localhost url validation

Open zakashe opened this issue 6 years ago • 11 comments

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?

zakashe avatar Aug 01 '18 12:08 zakashe

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

vict-shevchenko avatar Aug 02 '18 11:08 vict-shevchenko

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.

zakashe avatar Aug 10 '18 14:08 zakashe

Looks like you are right.

vict-shevchenko avatar Aug 17 '18 12:08 vict-shevchenko

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

rosieks avatar Jan 18 '19 10:01 rosieks

Any news?

syabro avatar Dec 20 '19 07:12 syabro

I will get an update posted during holiday break

mikeerickson avatar Dec 20 '19 17:12 mikeerickson

@mikeerickson any update maybe? :)

syabro avatar Dec 12 '20 15:12 syabro

@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.

mikeerickson avatar Dec 12 '20 21:12 mikeerickson

Fixed in 3.23 release (pending tagging)

mikeerickson avatar Dec 12 '20 21:12 mikeerickson

Thanks!

syabro avatar Dec 13 '20 09:12 syabro

@mikeerickson any news? :) 2023 :)

max-prtsr avatar Aug 21 '23 09:08 max-prtsr