-
Notifications
You must be signed in to change notification settings - Fork 116
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
FullUrl regex needs improvement #138
Comments
You can assign the issue to me, I can create a PR. |
There's an open PR in the linked repo to further improve that regex: asaskevich/govalidator#451 |
hi @junaid-ali 😄 Can you create a PR? |
@inhere I'm still working on it. The regex in the other repo has some issues as well. What I'm trying to do is: instead of using a complex regex, I'm thinking of updating the method like this // IsFullURL string.
func IsFullURL(s string) bool {
if s == "" {
return false
}
u, err := url.Parse(s)
if err != nil {
return false
}
if u.Scheme != "" && !strings.Contains(URLSchema, u.Scheme) {
return false
}
if ip := net.ParseIP(u.Host); ip == nil {
return rxDNSName.MatchString(u.Host)
}
return false
} This also has an issue if the URL has a raw percentage sign instead of an HTML encode sign but that should be easy to fix. |
sorry still working on it. |
Describe the bug
Currently,
fullUrl
returns invalid URLs as valid ones. Same is the case withUrl
. We should improve the regex like here:https://github.com/asaskevich/govalidator/blob/master/patterns.go#L41
Examples:
To Reproduce
Add the above invalid URLs to
TestIsFullURL
function, the tests will pass.The text was updated successfully, but these errors were encountered: