-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
localhost does not pass a URL validation #26
Comments
Hi, Why would you validate this type of URL ? |
Well this is still a possible URL. Apart from that, you can assign any name to any IP in the hosts file and the URL using this name will be as valid as the localhost one I need this for the local development mostly |
You can use a pipe to add a domain to your URL. I can't edit the validator regex to let 'localhost' to be valid and impact all of others users of this package. |
Just found out that the current regex also treats I would say, this is not really a validator that really validates the URL. It bans lots of URLs that are valid but considered not useful for standard use cases. You can't set your home page to be localhost or the IP from the private / intranet range, but it does not anyhow mean that this is not a URL. However I really understand that changing this behaviour is a breaking change and also I understand that this is the inheritance you got from the original project. Thank you for supporting this library! More to some sort of solution: would adding another validator make sense? Or just extending the validator with a parameter "isPublicUrl" = (by default) true which means the current behaviour and if false then a standard URL validation allowing any domain name and IP is applied? |
Thanks for the feedback, I guess the best choice is to keep simple regex to validate any data. An IPValidator should comes up with the possibility to combine multiple validators with an OR. new FormControl(value, [Validators.required, CustomValidators.or(CustomValidators.IP, CustomValidators.url)] |
I would suggest adding the support for the localhost & IPs as part of the domain, and before each of them is should be the protocol part (aka "HTTP://"). |
Hi @rsaenen
the following URL does not pass the validation by URL
Is there a way to fix this?
The text was updated successfully, but these errors were encountered: