jquense / yup

Dead simple Object schema validation
MIT License
22.89k stars 933 forks source link

URL validation is loose #2059

Open madelineryder opened 1 year ago

madelineryder commented 1 year ago

Describe the bug URL validation is missing on the second 1/2 of the url

image

To Reproduce

Two invalid urls that pass validation

  1. https://www.google
  2. https://www.instagram

Expected behavior I expected that the regex would not match with the incomplete url stings mention in points 1&2

Platform (please complete the following information):

Additional context Add any other context about the problem here.

melvyn2 commented 1 year ago

At the same time, this regex blocks valid URLs like http://localhost/ because the domain is a TLD, and different IP formats like http://127.0/ and http://127/ (both valid).

To address the main bug of this issue, I don't know if that could be fixed without hard-coding a list of TLDs, which isn't a good solution (think internal domains & TLDs, for example). https://www.google is a valid URL, just not a registered domain.