Skip to content
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

Validation failing for IsURL() #445

Open
orangemail opened this issue Jun 11, 2021 · 4 comments
Open

Validation failing for IsURL() #445

orangemail opened this issue Jun 11, 2021 · 4 comments

Comments

@orangemail
Copy link

I tried this sample string as input for IsURL().
i.e
http://com/networks/

API is returning this as valid URL. Can you please correct it.

I saw this Regex in RFC 2396. Somehow if we can use if inside this API ...it will be more effective.

^(([^:/?#]+):)?(//([^/?#]))?([^?#])(?([^#]))?(#(.))?

@nathj07
Copy link
Contributor

nathj07 commented Jul 12, 2021

another example is http://invalid-link

@dipesh23-apt
Copy link

@orangemail
Thanks for noticing this issue.
I have opened pulled request to make sure the validation is correct for IsURL.
I hope it gets merged as early as possible so that the users further do not face difficulties.

  • How do you reproduce it?
    By updating the regular expression format for the URL, by correcting the misplaced brackets and updating the * character to
    '+'.The * char in regular expression mean the * means "0 or more occurrences of the preceding item" and + char means "1 or
    more occurrences of the preceding item"
    Also there was a misplaced bracket of the form: ( (exp1... ) OR exp2)....
    instead it should have been of the form: ( (exp1...) ) OR (exp2....)
    The * specified after the form (.[a-zA-Z])* means it can have nil (.com/.eu) but updating it to '+' ensures (.com/.in/.xyz) be
    specified in the url to make it a valid url

  • What was the previous behavior?
    Earlier it used to return true for http://abcd or xyz/qw

which infact is not a valid URL as the domain name is not specified(.com/.eu/.in should be in the URL)
which in turn makes the 'govalidator package' work similar to the net/url package with a bug.

  • What is the current behavior?
    After modifying it, it returns false for http://abcd or wxe/123 or nmhih
    and in turn returns true for http://abcd.eu or xyz.ab or jkl.com

@dipesh23-apt
Copy link

#451 - Fix: Checking of a Valid URL or not

@sergeyglazyrindev
Copy link

Hello guys!
I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back
Link to my repo: create issue there and we'll discuss it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants