This is the best way that I think should be used to check URLs
reg = /https?:\/\/w{0,3}\w*?\.(\w*?\.)?\w{2,3}\S*|www\.(\w*?\.)?\w*?\.\w{2,3}\S*|(\w*?\.)?\w*?\.\w{2,3}[\/\?]\S*/ reg.test('www.google.com') # will return true reg.test('www.google') # will return false
Let me know if you still misunderstood.
source share