TheAlgorithms/JavaScript

Validate Url Issues

meirroth opened this issue · 9 comments

Two issues found with the Validate Url algorithm:

  1. A string is considered to be valid URL if it starts with www. even though it does not have https
  • validateUrl('www.google.com') // returns true
  • validateUrl('google.com') // returns false
  1. A valid URL returns false if starts with www like:
  • validateUrl('https://wwwdomain.com') // returns false

Can i try this

Can i try this

No (see the current PR).

is it still open?

Yesn't? The solution might be a removal of the "algorithm" though.

Hmm. None of those test cases are valid email addresses.

validateEmail('www.google.com') // returns true ❓

@trasherdk Oops... It's a typo. Should say validateUrl('www.google.com').
Fixed now.

Is this issue still open?

Is this issue still open?

Yes, but bear in mind that validating URLs is much more complex than presented here:

URL syntax diagram

(from https://en.wikipedia.org/wiki/URL)

hello, I would like to work on this.