Fix: Checking of a Valid URL or not #451
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Are you fixing a bug or providing a failing unit test to demonstrate a bug?
Yes, For checking a valid URL
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
Explain why the changes are necessary
To check for a valid URL, there are two packages net/url and the govalidator package.But if this package does not return the
correct output, there is no difference between the faulty package(net/url) and this one.
So to be at a higher level and simplify the complexities of the user this commit needs to be merged.Also in various projects
the checking of a valid URL is a crucial part, hence forth moving forward.